#==============================================================================
# ■ Scene_Base
#------------------------------------------------------------------------------
# 游戏中全部场景的公用模块。
#==============================================================================
module Scene_Base
include SailCat::Core_Config
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
return unless need_create?
SceneManager.start
create
post_create
Graphics.transition unless @custom_transition
update_scene until $scene != self
Graphics.freeze
pre_terminate
terminate
end
#--------------------------------------------------------------------------
# ● 建立预判
#--------------------------------------------------------------------------
def need_create?
true
end
#--------------------------------------------------------------------------
# ● 建立场景
#--------------------------------------------------------------------------
def create
execute_method_set([:prepare_data, :create_spriteset,
:create_all_sprites, :create_all_windows])
end
#--------------------------------------------------------------------------
# ● 设置场景
#--------------------------------------------------------------------------
def post_create; execute_method_set("post_create"); end
#--------------------------------------------------------------------------
# ● 更新场景
#--------------------------------------------------------------------------
def update_scene
Graphics.update
Input.update
update
end
#--------------------------------------------------------------------------
# ● 终止场景
#--------------------------------------------------------------------------
def pre_terminate; execute_method_set("pre_terminate"); end
#--------------------------------------------------------------------------
# ● 结束场景
#--------------------------------------------------------------------------
def terminate
dispose_spriteset
dispose_all_sprites
dispose_all_windows
after_effect
end
#--------------------------------------------------------------------------
# ● 更新窗口
#--------------------------------------------------------------------------
def update_all_windows
ivar = instance_variables.map {|i| instance_variable_get(i)}.flatten
ivar.each {|i| i.update if i.is_a?(Window) and not i.disposed?}
end
#--------------------------------------------------------------------------
# ● 释放精灵组
#--------------------------------------------------------------------------
def dispose_spriteset
ivar = instance_variables.map {|i| instance_variable_get(i)}.flatten
ivar.each {|i| i.dispose if i.is_a?(Spriteset)}
end
#--------------------------------------------------------------------------
# ● 释放精灵
#--------------------------------------------------------------------------
def dispose_all_sprites
ivar = instance_variables.map {|i| instance_variable_get(i)}.flatten
ivar.each do |i|
if i.is_a?(Sprite) and not i.disposed?
i.bitmap.dispose unless i.bitmap.disposed?
i.dispose
end
end
end
#--------------------------------------------------------------------------
# ● 释放窗口
#--------------------------------------------------------------------------
def dispose_all_windows
ivar = instance_variables.map {|i| instance_variable_get(i)}.flatten
ivar.each {|i| i.dispose if i.is_a?(Window) and not i.disposed?}
end
#--------------------------------------------------------------------------
# ● 结束效果
#--------------------------------------------------------------------------
def after_effect
end
end