Project1
标题:
Scene类start时的SceneManager.scene问题
[打印本页]
作者:
MCCF
时间:
2019-1-12 16:55
标题:
Scene类start时的SceneManager.scene问题
class Scene_Base
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
alias scene_help_start start
def start
scene_help_start
create_scene_help_window
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
alias scene_help_update update
def update
scene_help_update
update_scene_help_window if scene_id
end
#--------------------------------------------------------------------------
# ● 释放所有窗口
#--------------------------------------------------------------------------
alias scene_help_dispose_all_windows dispose_all_windows
def dispose_all_windows
scene_help_dispose_all_windows
@scene_help_window.dispose if scene_id
end
#--------------------------------------------------------------------------
# ● 更新所有窗口
#--------------------------------------------------------------------------
alias scene_help_update_all_windows update_all_windows
def update_all_windows
scene_help_update_all_windows
@scene_help_window.update if scene_id
end
#--------------------------------------------------------------------------
# ● 获取当前场景在设定中的下标位置
#--------------------------------------------------------------------------
def scene_id
for i in 0..SceneHelp::SCENE_NAME.length - 1
if SceneHelp::SCENE_NAME[i] == SceneManager.scene.class
return i
end
end
return nil
end
#--------------------------------------------------------------------------
# ● 生成场景说明窗口
#--------------------------------------------------------------------------
def create_scene_help_window
text = SceneHelp::HELP[scene_id]
@scene_help_window = Window_SceneHelp.new(1, text)
@scene_help_window.x = Graphic.width / 2 + SceneHelp::OFFSET_X - @scene_help_window.width / 2
@scene_help_window.y = Graphic.height / 2 + SceneHelp::OFFSET_Y - @scene_help_window.height / 2
@scene_help_window.z = 5000
end
#--------------------------------------------------------------------------
# ● 场景说明窗口的显示刷新
#--------------------------------------------------------------------------
def update_scene_help_window
if Input.press(SceneHelp::KEY[scene_id]) && !@scene_help_window.visible
@scene_help_window.show
elsif @scene_help_window.visible
@scene_help_window.hide
end
end
end
复制代码
这段代码中,实际上并没有运行
create_scene_help_window
,可是运行了
@scene_help_window.update
。结果,就发生了NoMethondError。
猜想应该是在start运行时
SceneManager.scene.class
并没有返回正确的类,那么怎样修改能使其返回当前切换至的场景类,或怎样用其他方法解决这个问题?
作者:
芯☆淡茹水
时间:
2019-1-12 17:38
本帖最后由 芯☆淡茹水 于 2019-1-12 17:40 编辑
照写法应该会运行 start ,除非后面有脚本直接把 Scene_Base 的 start 给吞了。
作者:
MCCF
时间:
2019-1-12 20:38
自己解决了,谢谢大佬!
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1