查看: 1183|回复: 1

[有事请教] [已解决]}一个场景两个定义两命令窗口光标移动不动

[复制链接]
梦石
0
星屑
7296
在线时间
1244 小时
注册时间
2015-8-15
回帖
473
发表于 2024-7-3 15:07:12 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 金芒芒 于 2024-7-5 16:43 编辑

[pre lang="ruby"]#==============================================================================
# ■ Scene_chuzhan
#------------------------------------------------------------------------------
#  处理菜单画面的类。
#==============================================================================

class Scene_chuzhan
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     chuzhan_index : 命令光标的初期位置
  #--------------------------------------------------------------------------
  def initialize(chuzhan_index = 0)
    @chuzhan_index = chuzhan_index
  end
  #--------------------------------------------------------------------------
  # ● 主处理
  #--------------------------------------------------------------------------
  def main
    # 生成地图背景
    @chezhan_TransparentBackground = Spriteset_Map.new
    # 生成出战菜单选项
    @chezhan_IndexCommand = Window_chuzhanCommand.new
    @chezhan_IndexCommand.index = @chuzhan_index
    # 生成阵位列表
    @zhenwei_IndexCommand = Window_zhenweiCommand.new
  #  @zhenwei_IndexCommand.index = @zhenwei_index

    # 冻结
    Graphics.transition
    # 不切换场景就一直循环
    update while $scene == self
    # 渐变
    Graphics.freeze
    @chezhan_IndexCommand.dispose
    @zhenwei_IndexCommand.dispose
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    Graphics.update
    Input.update

#    return chezhanUpdate_IndexCommand if @chezhan_IndexCommand.active
#   return zhenweiUpdate_IndexCommand if @zhenwei_IndexCommand.active

end

  #--------------------------------------------------------------------------
  # ● 刷新画面 (命令窗口被激活的情况下)
  #--------------------------------------------------------------------------
  def update_chezhan_IndexCommand

   @chezhan_IndexCommand.update
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      $scene = Scene_Map.new
      return
    end

    # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      # 命令窗口的光标位置分支
      case  @chezhan_IndexCommand.index
      when 0  # 队组1出生点
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        # 切换到物品画面
      # $game_switches[队伍1] = true #/ false
       $game_switches[20] = true
       $game_switches[21] = false
       $game_switches[22] = false
       $game_switches[23] = false
       $game_switches[24] = false
       @chezhan_IndexCommand.active = false
       @zhenwei_IndexCommand.active = true
       $scene = Scene_chuzhan.new
      when 1  # 队组2出生点
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        # 激活状态窗口


       $game_switches[20] = false
       $game_switches[21] = true
       $game_switches[22] = false
       $game_switches[23] = false
       $game_switches[24] = false
       @chezhan_IndexCommand.active = false
       @zhenwei_IndexCommand.active = true
     #  $scene = Scene_chuzhan.new
      when 2  # 队组3出生点
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        # 激活状态窗口


       $game_switches[20] = false
       $game_switches[21] = false
       $game_switches[22] = true
       $game_switches[23] = false
       $game_switches[24] = false
       @chezhan_IndexCommand.active = false
       @zhenwei_IndexCommand.active = true
      when 3  # 队组4出生点
        # 演奏确定 SE
       $game_system.se_play($data_system.decision_se)


       $game_switches[20] = false
       $game_switches[21] = false
       $game_switches[22] = false
       $game_switches[23] = true
       $game_switches[24] = false
       @chezhan_IndexCommand.active = false
       @zhenwei_IndexCommand.active = true

      when 4  # 队组5出生点
        # 演奏确定 SE
       $game_system.se_play($data_system.decision_se)


       $game_switches[20] = false
       $game_switches[21] = false
       $game_switches[22] = false
       $game_switches[23] = false
       $game_switches[24] = true
       @chezhan_IndexCommand.active = false
       @zhenwei_IndexCommand.active = true

     end

     
      return
    end
  end

  #--------------------------------------------------------------------------
  # ● 刷新画面 (命令窗口被激活的情况下)
  #--------------------------------------------------------------------------
  def update_zhenwei_IndexCommand
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      # 切换的地图画面
      $scene = Scene_Map.new
      return
    end
    # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      # 命令窗口的光标位置分支
      case @command_window.index
      when 0  # 队组1出生点
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        # 切换到物品画面
       # $出战1=[]
       if $game_switches[20] == true
         $出战1=[9.13]
        p $出战1
       end
        if $game_switches[21] == true
         $出战2=[9.113]
        p $出战2
       end

        $scene = Scene_chuzhan.new(1)
      when 1  # 队组2出生点
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        # 激活状态窗口
        $出战2=[]
       $scene = Scene_chuzhan.new(2)
      when 2  # 队组3出生点
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        # 激活状态窗口
       $出战3=[]
     $scene = Scene_chuzhan.new(3)
      when 3  # 队组4出生点
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
       $出战4=[]
        # 激活状态窗口
     $scene = Scene_chuzhan.new(4)

      when 4  # 队组5出生点
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
       $出战5=[]
        # 队组4出生点
      $scene = Scene_chuzhan.new(5)
      when 5  
        $game_system.se_play($data_system.decision_se)
       $出战=[]
      $scene = Scene_chuzhan.new(6)
      when 6  
        $game_system.se_play($data_system.decision_se)
       $出战=[]
      $scene = Scene_chuzhan.new(7)
      when 7  
        $game_system.se_play($data_system.decision_se)
       $出战=[]
      $scene = Scene_chuzhan.new(8)
      when 8  
        $game_system.se_play($data_system.decision_se)
       $出战=[]
      $scene = Scene_chuzhan.new(9)
      when 9  
        $game_system.se_play($data_system.decision_se)
       $出战=[]
       $scene = Scene_chuzhan.new(0)


      end
      return
    end
  end

end
[/pre][pre lang="ruby"]#==============================================================================
# ■ Window_MenuCommand
#------------------------------------------------------------------------------
#  菜单的命令选择行窗口。
#==============================================================================

class Window_chuzhanCommand < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     width    : 窗口的宽
  #     commands : 命令字符串序列
  #--------------------------------------------------------------------------
  def initialize
    width = 480 - 64
    s1 = "出战1"
    s2 = "出战2"
    s3 = "出战3"
    s4 = "出战4"
    s5 = "出战5"
    commands = [s1, s2, s3, s4, s5]
    # 由命令的个数计算出窗口的高
    super(32, 32, 160, 160)
    @item_max = commands.size
    @commands = commands
    self.contents = Bitmap.new(self.width - 32, commands.size / 2 * 32)
    self.back_opacity /= 2
    @column_max = 2
    @i = -1000
    @title_self_window = Window_Base.new(32 - 8, 32 - 8, 96, 24)
    @title_self_window.back_opacity /= 2
    @title_self_text = Sprite.new
    @title_self_text.bitmap = Bitmap.new(640, 480)
    @title_self_text.bitmap.clear
    @title_self_text.bitmap.font.size -=4
    @title_self_text.bitmap.font.name = "宋体"
    @title_self_text.bitmap.font.color = Color.new(0, 0, 0)
    @title_self_text.bitmap.draw_text(32 - 8, 32 - 12, 96, 32, "菜单选项", 1)
    @title_self_text.bitmap.font.color = Color.new(128, 255, 128)
    @title_self_text.bitmap.draw_text(32 - 8 - 1, 32 - 12 - 1, 96, 32, "菜单选项", 1)
    @title_self_text.z = 1000
    refresh
    self.index = 0
   
  end
  def item
    return @commands[self.index] == nil ? "" : @commands[self.index]
  end
  
  def dispose
    super
    if @title_self_text.bitmap != nil
      @title_self_text.bitmap.dispose
    end
    @title_self_text.dispose
    @title_self_window.dispose
  end
  
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      if self.index == i
        draw_item(i, normal_color, true)
      else
        draw_item(i, normal_color, false)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 描绘项目
  #     index : 项目编号
  #     color : 文字色
  #--------------------------------------------------------------------------
  def draw_item(index, color, flg)
    self.contents.font.color = color
    rect = Rect.new(index % 2 * 72, index / 2 * 32, (self.width - 32) / 2, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index], 1)
    if flg
      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
      self.contents.font.color = Color.new(0, 0, 0)
      self.contents.draw_text(rect, @commands[index], 1)
      rect = Rect.new(index % 2 * 72 - 1, index / 2 * 32 - 1, (self.width - 32) / 2, 32)
      self.contents.font.color = Color.new(255, 255, 225)
      self.contents.draw_text(rect, @commands[index], 1)
    end
  end
  #--------------------------------------------------------------------------
  # ● 项目无效化
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
  #--------------------------------------------------------------------------
  # ● 刷新光标矩形
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(@index % 2 * 72, @index / 2 * 32, (self.width - 32) / 2, 32)
    end
  end
  def update
    super
    if self.index != @i
      @i = self.index
      refresh
    end
  end
  
end
[/pre]
[/pre][pre lang="ruby"]
#==============================================================================
# ■ Window_MenuCommand
#------------------------------------------------------------------------------
#  菜单的命令选择行窗口。
#==============================================================================

class Window_zhenweiCommand < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     width    : 窗口的宽
  #     commands : 命令字符串序列
  #--------------------------------------------------------------------------
  def initialize
    width = 480 - 64
    s1 = "阵位1"
    s2 = "阵位2"
    s3 = "阵位3"
    s4 = "阵位4"
    s5 = "阵位5"
    s6 = "阵位6"
    s7 = "阵位7"
    s8 = "阵位8"
    s9 = "阵位9"
    s10 = "阵位10"

    commands = [s1, s2, s3, s4, s5,s6,s7,s8,s9,s10]
    # 由命令的个数计算出窗口的高
    super(32+160, 32, 160, 160)
    @item_max = commands.size
    @commands = commands
    self.contents = Bitmap.new(self.width - 32, commands.size / 2 * 32)
    self.back_opacity /= 2
    @column_max = 2
    @i = -1000
    @title_self_window = Window_Base.new(32 - 8, 32 - 8, 96, 24)
    @title_self_window.back_opacity /= 2
    @title_self_text = Sprite.new
    @title_self_text.bitmap = Bitmap.new(640, 480)
    @title_self_text.bitmap.clear
    @title_self_text.bitmap.font.size -=4
    @title_self_text.bitmap.font.name = "宋体"
    @title_self_text.bitmap.font.color = Color.new(0, 0, 0)
    @title_self_text.bitmap.draw_text(32 - 8, 32 - 12, 96, 32, "菜单选项", 1)
    @title_self_text.bitmap.font.color = Color.new(128, 255, 128)
    @title_self_text.bitmap.draw_text(32 - 8 - 1, 32 - 12 - 1, 96, 32, "菜单选项", 1)
    @title_self_text.z = 1000
    refresh
    self.index = 0
   
  end
  def item
    return @commands[self.index] == nil ? "" : @commands[self.index]
  end
  
  def dispose
    super
    if @title_self_text.bitmap != nil
      @title_self_text.bitmap.dispose
    end
    @title_self_text.dispose
    @title_self_window.dispose
  end
  
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      if self.index == i
        draw_item(i, normal_color, true)
      else
        draw_item(i, normal_color, false)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 描绘项目
  #     index : 项目编号
  #     color : 文字色
  #--------------------------------------------------------------------------
  def draw_item(index, color, flg)
    self.contents.font.color = color
    rect = Rect.new(index % 2 * 72, index / 2 * 32, (self.width - 32) / 2, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index], 1)
    if flg
      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
      self.contents.font.color = Color.new(0, 0, 0)
      self.contents.draw_text(rect, @commands[index], 1)
      rect = Rect.new(index % 2 * 72 - 1, index / 2 * 32 - 1, (self.width - 32) / 2, 32)
      self.contents.font.color = Color.new(255, 255, 225)
      self.contents.draw_text(rect, @commands[index], 1)
    end
  end
  #--------------------------------------------------------------------------
  # ● 项目无效化
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
  #--------------------------------------------------------------------------
  # ● 刷新光标矩形
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(@index % 2 * 72, @index / 2 * 32, (self.width - 32) / 2, 32)
    end
  end
  def update
    super
    if self.index != @i
      @i = self.index
      refresh
    end
  end
  
end
[/pre]
阵位.png
梦石
0
星屑
7296
在线时间
1244 小时
注册时间
2015-8-15
回帖
473
 楼主| 发表于 2024-7-5 16:42:47 | 显示全部楼层
  1. #==============================================================================
  2. # ■ Scene_chuzhan
  3. #------------------------------------------------------------------------------
  4. #  处理菜单画面的类。
  5. #==============================================================================

  6. class Scene_chuzhan
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #     chuzhan_index : 命令光标的初期位置,zhenwei_index = 9
  10.   #--------------------------------------------------------------------------
  11.   def initialize(chuzhan_index = 0)
  12.     @chuzhan_index = chuzhan_index
  13. #    @zhenwei_index = zhenwei_index
  14.     @wait_time = 0
  15.   end
  16.   #--------------------------------------------------------------------------
  17.   # ● 主处理
  18.   #--------------------------------------------------------------------------
  19.   def main
  20.     # 生成地图背景
  21.     @chezhan_TransparentBackground = Spriteset_Map.new
  22.     # 生成出战菜单选项
  23.     @chezhan_IndexCommand = Window_chuzhanCommand.new
  24.     @chezhan_IndexCommand.index = @chuzhan_index
  25.     # 生成阵位列表
  26.     @zhenwei_IndexCommand = Window_zhenweiCommand.new
  27.   #  @zhenwei_IndexCommand.index = false#@zhenwei_index

  28.     # 冻结
  29.     Graphics.transition
  30.     # 不切换场景就一直循环
  31.     update while $scene == self
  32.     # 渐变
  33.     Graphics.freeze
  34.     @chezhan_IndexCommand.dispose
  35.     @zhenwei_IndexCommand.dispose
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # ● 刷新画面
  39.   #--------------------------------------------------------------------------
  40.   def update
  41.     Graphics.update
  42.     Input.update
  43.     @wait_time -= 1
  44. # if @chezhan_IndexCommand.active == true
  45.     @chezhan_IndexCommand.update
  46.   #  end
  47.     update_chezhan_IndexCommand
  48.   # if @chezhan_IndexCommand.active == false
  49.    #   @zhenwei_IndexCommand.update
  50.    #   update_zhenwei_IndexCommand
  51.    #  end
  52. #   return zhenweiUpdate_IndexCommand if@chezhan_IndexCommand.active
  53. #  return zhenweiUpdate_IndexCommand if @zhenwei_IndexCommand.active =nil

  54. end

  55.   #--------------------------------------------------------------------------
  56.   # ● 刷新画面 (命令窗口被激活的情况下)
  57.   #--------------------------------------------------------------------------
  58.   def update_chezhan_IndexCommand

  59.   # @chezhan_IndexCommand.update
  60.     # 按下 B 键的情况下
  61.     if Input.trigger?(Input::B)
  62.       $scene = Scene_Map.new
  63.       return
  64.     end

  65.     # 按下 C 键的情况下
  66.     if Input.trigger?(Input::C)
  67.       # 命令窗口的光标位置分支
  68.       case  @chezhan_IndexCommand.index
  69.       when 0  # 队组1出生点
  70.         # 演奏确定 SE
  71.         $game_system.se_play($data_system.decision_se)
  72.         # 切换到物品画面
  73.       # $game_switches[队伍1] = true #/ false
  74.        $game_switches[20] = true
  75.        $game_switches[21] = false
  76.        $game_switches[22] = false
  77.        $game_switches[23] = false
  78.        $game_switches[24] = false
  79. #      @chezhan_IndexCommand.active = false
  80. #      @zhenwei_IndexCommand.active = true
  81.        $scene = Scene_zhenwei.new(0)
  82.    #    @zhenwei_IndexCommand.update
  83.       # update_zhenwei_IndexCommand
  84.       # $scene = Scene_chuzhan.new(5)
  85.       when 1  # 队组2出生点
  86.         # 演奏确定 SE
  87.         $game_system.se_play($data_system.decision_se)
  88.         # 激活状态窗口


  89.        $game_switches[20] = false
  90.        $game_switches[21] = true
  91.        $game_switches[22] = false
  92.        $game_switches[23] = false
  93.        $game_switches[24] = false
  94.        $scene = Scene_zhenwei.new(0)
  95.      #  $scene = Scene_chuzhan.new
  96.       when 2  # 队组3出生点
  97.         # 演奏确定 SE
  98.         $game_system.se_play($data_system.decision_se)
  99.         # 激活状态窗口


  100.        $game_switches[20] = false
  101.        $game_switches[21] = false
  102.        $game_switches[22] = true
  103.        $game_switches[23] = false
  104.        $game_switches[24] = false
  105.        @chezhan_IndexCommand.active = false
  106.        @zhenwei_IndexCommand.active = true
  107.       when 3  # 队组4出生点
  108.         # 演奏确定 SE
  109.        $game_system.se_play($data_system.decision_se)


  110.        $game_switches[20] = false
  111.        $game_switches[21] = false
  112.        $game_switches[22] = false
  113.        $game_switches[23] = true
  114.        $game_switches[24] = false
  115.        @chezhan_IndexCommand.active = false
  116.        @zhenwei_IndexCommand.active = true

  117.       when 4  # 队组5出生点
  118.         # 演奏确定 SE
  119.        $game_system.se_play($data_system.decision_se)


  120.        $game_switches[20] = false
  121.        $game_switches[21] = false
  122.        $game_switches[22] = false
  123.        $game_switches[23] = false
  124.        $game_switches[24] = true
  125.        @chezhan_IndexCommand.active = false
  126.        @zhenwei_IndexCommand.active = true

  127.      end

  128.      
  129.       return
  130.     end
  131.   end

  132.   #--------------------------------------------------------------------------
  133.   # ● 刷新画面 (命令窗口被激活的情况下)
  134.   #--------------------------------------------------------------------------
  135.   def update_zhenwei_IndexCommand
  136.       
  137.   #  end
  138.    # update_zhenwei_IndexCommand
  139.     # 按下 B 键的情况下
  140.     if Input.trigger?(Input::B)
  141.       # 演奏取消 SE
  142.       $game_system.se_play($data_system.cancel_se)
  143.       # 切换的地图画面
  144.       $scene = Scene_Map.new
  145.       return
  146.     end
  147.     # 按下 C 键的情况下
  148.     if Input.trigger?(Input::C)
  149.       # 命令窗口的光标位置分支
  150.       case @zhenwei_IndexCommand.index
  151.       when 0  # 队组1出生点
  152.         # 演奏确定 SE
  153.         $game_system.se_play($data_system.decision_se)
  154.         # 切换到物品画面
  155.        # $出战1=[]

  156.       $scene = Scene_zhenwei.new
  157.        # $scene = Scene_chuzhan.new(1)
  158.       when 1  # 队组2出生点
  159.         # 演奏确定 SE
  160.         $game_system.se_play($data_system.decision_se)
  161.         # 激活状态窗口
  162.      #   $出战2=[]
  163.       $scene = Scene_zhenwei.new
  164.       when 2  # 队组3出生点
  165.         # 演奏确定 SE
  166.         $game_system.se_play($data_system.decision_se)
  167.         # 激活状态窗口
  168.        $出战3=[]
  169.      $scene = Scene_chuzhan.new(3)
  170.       when 3  # 队组4出生点
  171.         # 演奏确定 SE
  172.         $game_system.se_play($data_system.decision_se)
  173.        $出战4=[]
  174.         # 激活状态窗口
  175.      $scene = Scene_chuzhan.new(4)

  176.       when 4  # 队组5出生点
  177.         # 演奏确定 SE
  178.         $game_system.se_play($data_system.decision_se)
  179.        $出战5=[]
  180.         # 队组4出生点
  181.       $scene = Scene_chuzhan.new(5)
  182.       when 5  
  183.         $game_system.se_play($data_system.decision_se)
  184.        $出战=[]
  185.       $scene = Scene_chuzhan.new(6)
  186.       when 6  
  187.         $game_system.se_play($data_system.decision_se)
  188.        $出战=[]
  189.       $scene = Scene_chuzhan.new(7)
  190.       when 7  
  191.         $game_system.se_play($data_system.decision_se)
  192.        $出战=[]
  193.       $scene = Scene_chuzhan.new(8)
  194.       when 8  
  195.         $game_system.se_play($data_system.decision_se)
  196.        $出战=[]
  197.       $scene = Scene_chuzhan.new(9)
  198.       when 9  
  199.         $game_system.se_play($data_system.decision_se)
  200.        $出战=[]
  201.        $scene = Scene_chuzhan.new(0)


  202.       end
  203.       return
  204.     end
  205.   end

  206. end
复制代码
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部