Project1

标题: 菜单进行修改后出现不明bug [打印本页]

作者: 酸酸_脑子报废中    时间: 2015-7-5 17:31
标题: 菜单进行修改后出现不明bug
本帖最后由 酸酸_脑子报废中 于 2015-7-5 17:31 编辑

    这里新人qaq
    是这样的 看了主站http://6rweb.sinaapp.com/articles/4860  的视频教程后修改,但是出现了在菜单中存档和物品点击下去都打不开,还有一个早一点的bug是点击一栏后返回,光标会出现在下一行(只有半行),可本身并没有设计那么多行qaq
    求大神指教qaq谢谢
    这个是第一个bug


然后是 修改过的脚本【不懂怎么添加脚本 只能这样了
#==============================================================================
# ■ Scene_Menu
#------------------------------------------------------------------------------
#  处理菜单画面的类。
#==============================================================================

class Scene_Menu
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     menu_index : 命令光标的初期位置
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  #--------------------------------------------------------------------------
  # ● 主处理
  #--------------------------------------------------------------------------
  def main
    # 生成命令窗口
    #s1 = "  故事之物 "
    #s2 = " 使用书签 "
    #s3 = "迂回之地 "
    @command_window = Window_Menu.new#(80, [s1, s2, s3])
    @command_window.index = @menu_index
    # 同伴人数为 0 的情况下
    if $game_party.actors.size == 0
      # 物品无效化
      @command_window.disable_item(0)
      @command_window.disable_item(1)
      @command_window.disable_item(2)
      @command_window.disable_item(3)
    end
    # 禁止存档的情况下
    if $game_system.save_disabled
      # 存档无效
      @command_window.disable_item(3)
    end
    # 生成状态窗口
    @status_window = Window_MenuStatus.new
    @status_window.x = 0
    @status_window.y = 0
    # 执行过渡
    Graphics.transition
    # 主循环
    loop do
      # 刷新游戏画面
      Graphics.update
      # 刷新输入信息
      Input.update
      # 刷新画面
      update
      # 如果切换画面就中断循环
      if $scene != self
        break
      end
    end
    # 准备过渡
    Graphics.freeze
    # 释放窗口
    @command_window.dispose
    @status_window.dispose
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    # 刷新窗口
    @command_window.update
    @status_window.update
    # 命令窗口被激活的情况下: 调用 update_command
    if @command_window.active
      update_command
      return
    end
    # 状态窗口被激活的情况下: 调用 update_status
    if @status_window.active
      update_status
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面 (命令窗口被激活的情况下)
  #--------------------------------------------------------------------------
  def update_command
    # 按下 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)
      # 同伴人数为 0、存档、游戏结束以外的场合
      if $game_party.actors.size == 0 and @command_window.index < 3
        # 演奏冻结 SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # 命令窗口的光标位置分支
      case @command_window.index
      when 0  # 物品
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        # 切换到物品画面
        $data_system.words.item
      when 1  # 存档
        # 禁止存档的情况下
        if " 存档 "
          # 演奏确定 SE
          $game_system.se_play($data_system.decision_se)
          return
        end
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        # 切换到存档画面
        $scene = Scene_Save.new
      when 2  # 游戏结束
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        # 切换到游戏结束画面
        $scene = Scene_End.new
      end
      return
    end
  end
end











(第二个)

    #==============================================================================
# ■ Window_Menu
#------------------------------------------------------------------------------
#  菜单命令选择行窗口。
#==============================================================================
class Window_Menu < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     width    : 窗口的宽
  #     commands : 命令字符串序列
  #--------------------------------------------------------------------------
  def initialize#(width, commands)
    # 由命令的个数计算出窗口的高
    super(160, 0, 480, 64)
    @commands = ["  故事之物 ", " 使用书签 ", "迂回之地 "]
    @column_max = 3   
    @item_max = @commands.size
    self.z = 150
    self.contents = Bitmap.new(480-32, 32)
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
  end
  #--------------------------------------------------------------------------
  # ● 描绘项目
  #     index : 项目编号
  #     color : 文字色
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(170 * index, 1, self.contents.width - 8, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index])
  end
  #--------------------------------------------------------------------------
  # ● 项目无效化
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
  #--------------------------------------------------------------------------
  # ● 刷新光标矩形
  #--------------------------------------------------------------------------
  def update_cursor
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
  end
end











(第三个)
#==============================================================================
# ■ Window_Item
#------------------------------------------------------------------------------
#  物品画面、战斗画面、显示浏览物品的窗口。
#==============================================================================

class Window_Item < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 640, 416)
    @column_max = 2
    refresh
    self.index = 0
    # 战斗中的情况下将窗口移至中央并将其半透明化
    if $game_temp.in_battle
      self.y = 64
      self.height = 256
      self.back_opacity = 160
    end
  end
  #--------------------------------------------------------------------------
  # ● 获取物品
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # 添加物品
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items)
      end
    end
    # 在战斗中以外添加武器、防具
    unless $game_temp.in_battle
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0
          @data.push($data_weapons)
        end
      end
      for i in 1...$data_armors.size
        if $game_party.armor_number(i) > 0
          @data.push($data_armors)
        end
      end
    end
    # 如果项目数不是 0 就生成位图、重新描绘全部项目
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 描绘项目
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    if item.is_a?(RPG::Item) and
       $game_party.item_can_use?(item.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # ● 刷新帮助文本
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end








(第四个)
#==============================================================================
# ■ Window_MenuStatus
#------------------------------------------------------------------------------
#  显示菜单画面和同伴状态的窗口。
#==============================================================================

class Window_MenuStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化目标
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
    self.active = false
    self.index = -1
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    for i in 0...$game_party.actors.size
      x = 64
      y = (i+1) * 116 +35
      actor = $game_party.actors
      bitmap = Bitmap.new("Graphics/sour/" + active.id.to_s + "_h")#RPG::Cache.character(actor.character_name, actor.character_hue)
      cw = bitmap.width
      ch = bitmap.height
      src_rect = Rect.new(0, 0, cw, ch)
      self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
      draw_actor_name(actor, x+80,y-75)
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新光标矩形
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(0, @index * 110+50, 210, 105)
      refresh
    draw_status
   end
  end
  def draw_status
    actor = $game_party.actors[@index]
    bitmap = Bitmap.new("Graphics/sour/" + active.id.to_s + "_b")
    src_rect = Rect.new(0, 0, bitmap,width. bitmap.height)
    self.centent.blt(100, 50, bltmap. src_rect,255)
    draw_actor_graphic(@actor, 130 + 96,64)
    draw_actor_name(@actor, 130 + 96,64)
    draw_actor_class(@actor, 428,64)
    draw_actor_level(@actor, 230 + 36,64)
    draw_actor_state(@actor, 430 + 36,64)
    draw_actor_hp(@actor, 130 + 96,112,172)
    draw_actor_sp(@actor, 130 + 96,112,172)
    draw_actor_parameter(@actor, 130 + 96,192,0)
    draw_actor_parameter(@actor, 130 + 96,368,1)
    draw_actor_parameter(@actor, 130 + 96,400,2)
    self.contents.font.color = system_color
    self.contents.draw_text(130 + 320, 112, 80, 32, "EXP")
    self.contents.draw_text(130 + 320, 114, 80, 32, "NEXT")
    self.contents.font.color = normal_color
    self.contents.draw_text(130 + 320 , 80, 84, 32, @actor.exp_s, 2)
    self.contents.draw_text(130 + 320 , 80, 84, 32, @actor.next_rest_exp_s, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(90, 320, 208, 96, 32, "故事之物")
    draw_item_name($data_weapons[@actor.weapon_id], 130 + 320 + 16, 208)
    draw_item_name($data_armors[@actor.armor1_id], 130 + 320 + 16, 256)
    draw_item_name($data_armors[@actor.armor2_id], 130 + 320 + 16, 304)
    draw_item_name($data_armors[@actor.armor3_id], 130 + 320 + 16, 352)
    draw_item_name($data_armors[@actor.armor4_id], 130 + 320 + 16, 400)

  end
end








谢谢qaq
作者: kuerlulu    时间: 2015-7-5 20:39
很多地方都写得不对 要不然你加我qq947375548, 下面是已经能用的代码
修改后





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