Project1

标题: 关于变量控制的~ [打印本页]

作者: neverstop    时间: 2014-8-21 18:16
标题: 关于变量控制的~

就是想在打开菜单是变量2会 = 7,而关闭菜单时,变量2 会=2

                                                                          就是这样。
作者: 喵呜喵5    时间: 2014-8-21 18:20
本帖最后由 喵呜喵5 于 2014-8-21 20:08 编辑
  1. class Scene_Menu
  2.   alias m5_20140821_start start
  3.   def start
  4.     $game_variables[2] = 7
  5.     m5_20140821_start   
  6.   end
  7.   alias m5_20140821_return_scene return_scene
  8.   def return_scene
  9.     $game_variables[2] = 2
  10.     m5_20140821_return_scene
  11.   end
  12. end
复制代码

作者: 喵呜喵5    时间: 2014-8-21 19:52
测试过了,即使是原来的脚本我这边变量的值也是正常的啊

我稍微修改了二楼的代码,再试试吧,如果不行的话试试下面这段代码
  1. class Game_Variables
  2.   alias m5_20140821_get []
  3.   def [](variable_id)
  4.     if variable_id == 2
  5.       return SceneManager.scene.is_a?(Scene_MenuBase)? 7 : 2
  6.     else
  7.       return m5_20140821_get(variable_id)
  8.     end   
  9.   end
  10. end
复制代码
如果还是不行的话,我觉得是你使用的脚本的问题,请附上你使用的那个脚本




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