Project1

标题: 给脚本添加开关的问题 [打印本页]

作者: calvin0703    时间: 2011-3-18 22:25
标题: 给脚本添加开关的问题
  1. #==============================================================================
  2. # ■ Window_Actorlevel
  3. #------------------------------------------------------------------------------
  4. #  显示角色等级的窗口。
  5. #==============================================================================

  6. class Window_Actorlevel < Window_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #     actor : 角色
  10.   #--------------------------------------------------------------------------
  11.   def initialize
  12.     super(80, -9, 640, 100)
  13.     self.contents = Bitmap.new(width - 32, height - 32)
  14.     self.opacity = 0
  15.     refresh
  16.   end
  17.   #--------------------------------------------------------------------------
  18.   # ● 刷新
  19.   #--------------------------------------------------------------------------
  20.   def refresh
  21.     self.contents.clear
  22.     for i in 0...$game_party.actors.size
  23.       actor = $game_party.actors[i]
  24.       actor_x = i * 160
  25.       draw_actor_level(actor, actor_x, 10)
  26.     end
  27.   end
  28. end

  29. class Scene_Map
  30.   alias old_main main
  31.   def main
  32.     @Window_Actorlevel = Window_Actorlevel.new
  33.     old_main
  34.     @Window_Actorlevel.dispose
  35.   end
  36. end
复制代码
这是忧雪の伤大大给的显示角色等级脚本 我想要给这脚本弄个开关 XX开关打开 脚本就会停止运行  该怎么弄???
dsu_plus_rewardpost_czw
作者: 天帝·隳    时间: 2011-3-18 23:19
本帖最后由 天帝·隳 于 2011-3-18 23:19 编辑
  1.  
  2.  #--------------------------------------------------------------------------
  3.   # ● 刷新
  4.   #--------------------------------------------------------------------------
  5.   def refresh
  6.     self.contents.clear
  7.     #如果1號開關打開~
  8.     if $game_switches[1] == true
  9.        for i in 0...$game_party.actors.size
  10.          actor = $game_party.actors[i]
  11.          actor_x = i * 160
  12.          draw_actor_level(actor, actor_x, 10)
  13.        end
  14.     end
  15.   end
复制代码

作者: Wind2010    时间: 2011-3-19 11:50
回复 天帝·隳 的帖子

最上面加
class Window_Actorlevel < Window_Base
然后下面多加一个end?
作者: 天帝·隳    时间: 2011-3-19 17:17
……直接修改那個refresh定義~
作者: 忧雪の伤    时间: 2011-3-19 17:43
  1. id = 5 # 开关id
  2. class Scene_Map
  3.   alias old_update update
  4.   def update
  5.     case $game_switches[id]
  6.     when true
  7.       @Window_Actorlevel.visible = false
  8.     when false
  9.       @Window_Actorlevel.visible = true
  10.     end
  11.     old_update
  12.   end
  13. end
复制代码

作者: 沙漠点灰    时间: 2011-3-19 17:55
回复 calvin0703 的帖子
  1. #==============================================================================
  2. # ■ Window_Actorlevel
  3. #------------------------------------------------------------------------------
  4. #  显示角色等级的窗口。
  5. #==============================================================================

  6. class Window_Actorlevel < Window_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #     actor : 角色
  10.   #--------------------------------------------------------------------------
  11.   def initialize
  12.     super(80, -9, 640, 100)
  13.     self.contents = Bitmap.new(width - 32, height - 32)
  14.     self.opacity = 0
  15.     refresh
  16.   end
  17.   #--------------------------------------------------------------------------
  18.   # ● 刷新
  19.   #--------------------------------------------------------------------------
  20.   def refresh
  21.     self.contents.clear
  22.     for i in 0...$game_party.actors.size
  23.       actor = $game_party.actors[i]
  24.       actor_x = i * 160
  25.       draw_actor_level(actor, actor_x, 10)
  26.     end
  27.   end
  28. end

  29. class Scene_Map
  30.   alias old_main main
  31.   def main
  32.     @Window_Actorlevel = Window_Actorlevel.new
  33.     @Window_Actorlevel.visible = false
  34.     old_main
  35.     @Window_Actorlevel.dispose
  36.   end
  37.   alias old_update update
  38.   def update
  39.     @Window_Actorlevel.visible = $game_switches[1]
  40.     old_update
  41.   end
  42. end
复制代码
脚本中 $game_switches 的[]里面是开关的编号...
打开是显示,关掉是隐藏

直接 visible 就好了嘛 干吗重新定义refresh
作者: 忧雪の伤    时间: 2011-3-19 18:50
沙漠点灰 发表于 2011-3-19 17:55
回复 calvin0703 的帖子

脚本中 $game_switches 的[]里面是开关的编号...

汝要知道我是脚本作者……
不是我来解决的话挺囧。




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