设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1861|回复: 2
打印 上一主题 下一主题

[已经解决] Scene类start时的SceneManager.scene问题

[复制链接]

Lv4.逐梦者

梦石
2
星屑
6639
在线时间
501 小时
注册时间
2018-3-23
帖子
533

R考场第七期银奖

跳转到指定楼层
1
发表于 2019-1-12 16:55:49 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
  1. class Scene_Base
  2.   #--------------------------------------------------------------------------
  3.   # ● 开始处理
  4.   #--------------------------------------------------------------------------
  5.   alias scene_help_start start
  6.   def start
  7.     scene_help_start
  8.     create_scene_help_window
  9.   end
  10.   #--------------------------------------------------------------------------
  11.   # ● 更新画面
  12.   #--------------------------------------------------------------------------
  13.   alias scene_help_update update
  14.   def update
  15.     scene_help_update
  16.     update_scene_help_window if scene_id
  17.   end
  18.   #--------------------------------------------------------------------------
  19.   # ● 释放所有窗口
  20.   #--------------------------------------------------------------------------
  21.   alias scene_help_dispose_all_windows dispose_all_windows
  22.   def dispose_all_windows
  23.     scene_help_dispose_all_windows
  24.     @scene_help_window.dispose if scene_id
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # ● 更新所有窗口
  28.   #--------------------------------------------------------------------------
  29.   alias scene_help_update_all_windows update_all_windows
  30.   def update_all_windows
  31.     scene_help_update_all_windows
  32.     @scene_help_window.update if scene_id
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # ● 获取当前场景在设定中的下标位置
  36.   #--------------------------------------------------------------------------
  37.   def scene_id
  38.     for i in 0..SceneHelp::SCENE_NAME.length - 1
  39.       if SceneHelp::SCENE_NAME[i] == SceneManager.scene.class
  40.         return i
  41.       end
  42.     end
  43.     return nil
  44.   end
  45.   #--------------------------------------------------------------------------
  46.   # ● 生成场景说明窗口
  47.   #--------------------------------------------------------------------------
  48.   def create_scene_help_window
  49.     text = SceneHelp::HELP[scene_id]
  50.     @scene_help_window = Window_SceneHelp.new(1, text)
  51.     @scene_help_window.x = Graphic.width / 2 + SceneHelp::OFFSET_X - @scene_help_window.width / 2
  52.     @scene_help_window.y = Graphic.height / 2 + SceneHelp::OFFSET_Y - @scene_help_window.height / 2
  53.     @scene_help_window.z = 5000
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ● 场景说明窗口的显示刷新
  57.   #--------------------------------------------------------------------------
  58.   def update_scene_help_window
  59.     if Input.press(SceneHelp::KEY[scene_id]) && !@scene_help_window.visible
  60.       @scene_help_window.show
  61.     elsif @scene_help_window.visible
  62.       @scene_help_window.hide
  63.     end
  64.   end
  65. end
复制代码
这段代码中,实际上并没有运行create_scene_help_window,可是运行了@scene_help_window.update。结果,就发生了NoMethondError。

猜想应该是在start运行时SceneManager.scene.class并没有返回正确的类,那么怎样修改能使其返回当前切换至的场景类,或怎样用其他方法解决这个问题?
祝好。

Lv5.捕梦者

梦石
0
星屑
31920
在线时间
5080 小时
注册时间
2012-11-19
帖子
4877

开拓者

2
发表于 2019-1-12 17:38:23 | 只看该作者
本帖最后由 芯☆淡茹水 于 2019-1-12 17:40 编辑

照写法应该会运行 start ,除非后面有脚本直接把 Scene_Base 的 start 给吞了。
xp vx va mv  va mz 各类型脚本/插件定制
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
2
星屑
6639
在线时间
501 小时
注册时间
2018-3-23
帖子
533

R考场第七期银奖

3
 楼主| 发表于 2019-1-12 20:38:05 | 只看该作者
自己解决了,谢谢大佬!
祝好。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-25 02:58

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表