Project1

标题: 在菜单中添加了新项目,打开后再返回菜单的脚本应该怎么 [打印本页]

作者: shinliwei    时间: 2010-12-10 14:01
标题: 在菜单中添加了新项目,打开后再返回菜单的脚本应该怎么
本帖最后由 shinliwei 于 2010-12-10 20:56 编辑


如图,我用了wangswz前辈的天赋技能树脚本,并且我把这项添加到菜单里了。
点击后选人物进入天赋界面,但是按范围时不回到菜单界面了,我看了下其他项目(如状态、装备)的脚本项,并按照样式进行修改,可是还是不返回菜单界面,因此特来请教诸位。
  1. #==============================================================================
  2. # ■ Scene_Skill_Tree
  3. #------------------------------------------------------------------------------
  4. #  天赋技能类
  5. #==============================================================================

  6. class Scene_Skill_Tree < Scene_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #     index : 天赋树
  10.   #--------------------------------------------------------------------------
  11.   def initialize(actor_index = 0)
  12.     @actor = actor_index
  13.   end
  14.   #--------------------------------------------------------------------------
  15.   # ● 开始处理
  16.   #--------------------------------------------------------------------------
  17.   def start
  18.     super
  19.     create_menu_background
  20.     start_command
  21.     @skill_tree_window = Window_Skill_Tree.new(272, 0, 272, 328, $game_party.members[@actor])
  22.     @skill_tree_window.active = false
  23.     @skill_tree_window.visible = false
  24.     @skill_tree_window.index = 2 #??
  25.     @base_window = Window_Base.new(272, 0, 272, 328)
  26.     @skill_status_window = Window_skill_status.new
  27.     @skill_status_window.visible = false
  28.     @base_window2 = Window_Base.new(0, 328, 544, 88)
  29.     @skill_actor_window = Window_actor_Tree.new($game_party.members[@actor])
  30.     @skill_actor_window.active = true
  31.     @skill_data = Window_skill_data.new($game_party.members[@actor].id)
  32.   end
  33.   #--------------------------------------------------------------------------
  34.   # ● 开始处理
  35.   #--------------------------------------------------------------------------
  36.   def start_command
  37.     s1 = FSL::ST::St_detailed[FSL::ST::St_class_id[$game_party.members[@actor].class_id][0]][1]
  38.     s2 = FSL::ST::St_detailed[FSL::ST::St_class_id[$game_party.members[@actor].class_id][1]][1]
  39.     s3 = FSL::ST::St_detailed[FSL::ST::St_class_id[$game_party.members[@actor].class_id][2]][1]
  40.     @command_window = Window_Command.new(272, [s1, s2, s3], 3)
  41.     @command_window.y = 88
  42.     @command_window.active = true
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # ● 结束处理
  46.   #--------------------------------------------------------------------------
  47.   def terminate
  48.     super
  49.     dispose_menu_background
  50.     @skill_tree_window.dispose
  51.     @base_window.dispose
  52.     @base_window2.dispose
  53.     @skill_data.dispose
  54.     @skill_status_window.dispose
  55.     @skill_actor_window.dispose
  56.     @command_window.dispose
  57.   end
  58. #--------------------------------------------------------------------------
  59.   # ● 回到原画面
  60.   #--------------------------------------------------------------------------
  61.   def return_scene
  62.     $scene = Scene_Menu.new(4)
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   # ● 切换至下一角色画面
  66.   #--------------------------------------------------------------------------
  67.   def next_actor
  68.     @actor_index += 1
  69.     @actor_index %= $game_party.members.size
  70.     $scene = Scene_Skill_Tree.new(@actor_index)
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # ● 切换至上一角色画面
  74.   #--------------------------------------------------------------------------
  75.   def prev_actor
  76.     @actor_index += $game_party.members.size - 1
  77.     @actor_index %= $game_party.members.size
  78.     $scene = Scene_Skill_Tree.new(@actor_index)
  79.   end      
  80.   #--------------------------------------------------------------------------
  81.   # ● 更新画面
  82.   #--------------------------------------------------------------------------
  83.   def update
  84.     super
  85.     @skill_tree_window.update
  86.     @skill_actor_window.update
  87.     @skill_status_window.update
  88.     @base_window.update
  89.     @base_window2.update
  90.     @skill_data.update
  91.     @command_window.update
  92.    
  93.     if @skill_actor_window.active
  94.       if @skill_tree_window.visible == false
  95.         if Input.trigger?(Input::R)
  96.           Sound.play_cursor
  97.           @actor += 1
  98.           @actor %= $game_party.members.size
  99.           $scene = Scene_Skill_Tree.new(@actor)
  100.           @skill_tree_window.ST_actor_data($game_party.members[@actor].id)
  101.         elsif Input.trigger?(Input::L)
  102.           Sound.play_cursor
  103.           @actor += $game_party.members.size - 1
  104.           @actor %= $game_party.members.size
  105.           $scene = Scene_Skill_Tree.new(@actor)
  106.           @skill_tree_window.ST_actor_data($game_party.members[@actor].id)
  107.         end
  108.       end
  109.     end

  110.     if @command_window.active
  111.       update_command_selection
  112.     elsif @skill_tree_window.active
  113.       update_skill_tree_selection
  114.     end
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # ● 更新命令窗口
  118.   #--------------------------------------------------------------------------
  119.   def update_command_selection
  120.     if Input.trigger?(Input::B)
  121.       Sound.play_cancel
  122.       $scene = Scene_Map.new
  123.     elsif Input.trigger?(Input::C)
  124.       case @command_window.index
  125.       when 0  # 第一天赋
  126.         Sound.play_decision
  127.         @command_window.active = false
  128.         @base_window.visible = false
  129.         @base_window2.visible = false
  130.         @skill_actor_window.active = false
  131.         @skill_tree_window.active = true
  132.         @skill_tree_window.visible = true
  133.         @skill_tree_window.index = FSL::ST::St_class_id[$game_party.members[@actor].class_id][0]
  134.         @skill_tree_window.ST_actor_data($game_party.members[@actor].id)
  135.         @skill_status_window.visible = true
  136.         @skill_status_window.skill = @skill_tree_window.STK
  137.       when 1  # 第二天赋
  138.         Sound.play_decision
  139.         @command_window.active = false
  140.         @base_window.visible = false
  141.         @base_window2.visible = false
  142.         @skill_actor_window.active = false
  143.         @skill_tree_window.active = true
  144.         @skill_tree_window.visible = true
  145.         @skill_tree_window.index = FSL::ST::St_class_id[$game_party.members[@actor].class_id][1]
  146.         @skill_tree_window.ST_actor_data($game_party.members[@actor].id)
  147.         @skill_status_window.visible = true
  148.         @skill_status_window.skill = @skill_tree_window.STK
  149.       when 2  # 第三天赋
  150.         Sound.play_decision
  151.         @command_window.active = false
  152.         @base_window.visible = false
  153.         @base_window2.visible = false
  154.         @skill_actor_window.active = false
  155.         @skill_tree_window.active = true
  156.         @skill_tree_window.visible = true
  157.         @skill_tree_window.index = FSL::ST::St_class_id[$game_party.members[@actor].class_id][2]
  158.         @skill_tree_window.ST_actor_data($game_party.members[@actor].id)
  159.         @skill_status_window.visible = true
  160.         @skill_status_window.skill = @skill_tree_window.STK
  161.       end
  162.     end
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # ● 更新天赋窗口
  166.   #--------------------------------------------------------------------------
  167.   def update_skill_tree_selection
  168.     if Input.trigger?(Input::B)
  169.       Sound.play_cancel
  170.       @command_window.active = true
  171.       @base_window.visible = true
  172.       @base_window2.visible = true
  173.       @skill_actor_window.active = true
  174.       @skill_tree_window.active = false
  175.       @skill_tree_window.visible = false
  176.       @skill_status_window.visible = false
  177.       @skill_tree_window.ST_actor_data2
  178.     end

  179.       if Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT) || Input.trigger?(Input::UP) || Input.trigger?(Input::DOWN) || Input.trigger?(Input::X)
  180.         @skill_status_window.skill = @skill_tree_window.STK
  181.         @skill_tree_window.ST_actor_data3
  182.         @skill_data.refresh
  183.       end
  184.     end
  185. end
复制代码

作者: Rion幻音    时间: 2010-12-10 14:48
本帖最后由 Rion幻音 于 2010-12-10 14:49 编辑

63行的
  1. $scene = Scene_Menu.new(X)
复制代码
X可自行设定……
作者: shinliwei    时间: 2010-12-10 15:16
回复 Rion幻音 的帖子

我设的是4啊,0—道具、1—技能、2—装备、3—状态、4—天赋。
作者: fux2    时间: 2010-12-10 16:34
没有定义按B的方法,会继承父类的方法,在update_command_selection追加按下B的事件
作者: shinliwei    时间: 2010-12-10 18:43
回复 fux2 的帖子

感谢您的指正!~~




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