Project1

标题: 怎样用开关来控制一个窗口的显示与关闭? [打印本页]

作者: maosi066rpg    时间: 2009-6-1 09:12
标题: 怎样用开关来控制一个窗口的显示与关闭?
怎样用开关来控制一个窗口的显示与关闭?
比如说下面这个脚本所显示的窗口
  1. $variables_id = 2
  2. $icon_index = 0
  3. class Window_Gold < Window_Base
  4.   def initialize (x, y)
  5.     super(160, 32, 352, 192)
  6.   self.opacity = 200
  7.   self.back_opacity = 200
  8.   self.contents_opacity = 255
  9.     @icon = 0
  10.     @variable = 0
  11.     refresh
  12.     end
  13.   def refresh
  14.       self.contents.clear
  15.       draw_icon($icon_index + 219,0,0,true)
  16.       draw_icon($icon_index + 216,0,28,true)
  17.       draw_icon($icon_index + 217,0,56,true)
  18.       draw_icon($icon_index + 219,296,0,true)
  19.       draw_icon($icon_index + 216,296,28,true)
  20.       draw_icon($icon_index + 217,296,56,true)
  21.       self.contents.draw_text(16,0,64,24,$game_variables[$variables_id + 4].to_s,2)
  22.       self.contents.draw_text(16,28,64,24,$game_variables[$variables_id + 5].to_s,2)
  23.       self.contents.draw_text(16,56,64,24,$game_variables[$variables_id + 6].to_s,2)
  24.       self.contents.draw_text(220,0,64,24,$game_variables[$variables_id + 10].to_s,3)
  25.       self.contents.draw_text(220,28,64,24,$game_variables[$variables_id + 11].to_s,3)
  26.       self.contents.draw_text(220,56,64,24,$game_variables[$variables_id + 12].to_s,3)
  27.       @icon = $icon_index
  28.       @variable = $game_variables[$variables_id]
  29.     end
  30.   end
复制代码



或者这种自定义窗口
要怎样才可以用开关控制
  1. $variables_id = 2
  2. $icon_index = 0
  3. class Window_Azd < Window_Base
  4.   def initialize
  5.     super(160, 32, 352, 192)
  6.   self.opacity = 150
  7.   self.back_opacity = 150
  8.     @icon = 0
  9.     @variable = 0
  10.     refresh
  11.   end
  12.   def refresh
  13.       self.contents.clear
  14.       draw_icon($icon_index + 219,0,0,true)
  15.       draw_icon($icon_index + 216,0,28,true)
  16.       draw_icon($icon_index + 217,0,56,true)
  17.       draw_icon($icon_index + 219,296,0,true)
  18.       draw_icon($icon_index + 216,296,28,true)
  19.       draw_icon($icon_index + 217,296,56,true)
  20.       self.contents.draw_text(16,0,64,24,$game_variables[$variables_id + 4].to_s,2)
  21.       self.contents.draw_text(16,28,64,24,$game_variables[$variables_id + 5].to_s,2)
  22.       self.contents.draw_text(16,56,64,24,$game_variables[$variables_id + 6].to_s,2)
  23.       self.contents.draw_text(220,0,64,24,$game_variables[$variables_id + 10].to_s,3)
  24.       self.contents.draw_text(220,28,64,24,$game_variables[$variables_id + 11].to_s,3)
  25.       self.contents.draw_text(220,56,64,24,$game_variables[$variables_id + 12].to_s,3)
  26.       @icon = $icon_index
  27.       @variable = $game_variables[$variables_id]
  28.   end
  29. end
  30. class Scene_Map < Scene_Base
  31.   alias new_start start
  32.   def start
  33.     new_start
  34.     @azd_window = Window_Azd.new
  35.   end
  36.   alias new_update update
  37.   def update
  38.     new_update
  39.     @azd_window.refresh
  40.   end
  41.   alias new_terminate terminate
  42.   def terminate
  43.     @azd_window.dispose
  44.     new_terminate
  45.   end
  46. end
复制代码





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1