class Window_Variables < Window_Base
def initialize
super(416,364,126,48) # 创建大小
@text = "" # 初始化内容
@variable = 0
refresh #调用refresh方法(下文定义)
end
def refresh #定义refresh方法
if $game_switches[$s_id] == true #判断是否显示窗口
self.visible = false
else
self.visible = true
end
if @text != $text or @variable != $game_variables[$v_id] #内容变化时
self.contents.clear #清除窗口的位图
self.contents.draw_text(0,0,94,24,$text) #重绘
self.contents.draw_text(0,0,94,24,$game_variables[$v_id].to_s,2)
@type = $type # 代入当前内容
@owner = $owner
end
end
end
class Scene_Map < Scene_Base
alias new_start start #生成窗体
def start
new_start
@varia_window = Window_Variables.new
end
alias new_update update #更新窗体
def update
new_update
@varia_window.refresh
end
alias new_terminate terminate #消除窗体
def terminate
@varia_window.dispose
new_terminate
end
end