查看: 2950|回复: 2

[已经解决] 其他4个光标不变最后一个光标移动一下位置

[复制链接]
梦石
0
星屑
7296
在线时间
1244 小时
注册时间
2015-8-15
回帖
473
发表于 2016-2-25 09:31:36 | 显示全部楼层 |阅读模式

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

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

×
[pre lang="ruby"]class Window_Equip_right < Window_Selectable#_New
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     actor : 角色
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(120, 104, 368, 400)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # ● 获取物品
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  
  def set_actor(actor)
    @actor = actor
    refresh
  end
  
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_name(@actor, 145, 0)
    @data = []
    @data.push($data_weapons[@actor.weapon_id])
    @data.push($data_armors[@actor.armor1_id])
    @data.push($data_armors[@actor.armor2_id])
    @data.push($data_armors[@actor.armor3_id])
    @data.push($data_armors[@actor.armor4_id])
    @item_max = @data.size
    self.contents.font.color = system_color
    y_r = 4 # 右窗口 y 坐标
    self.contents.font.size = 20
    draw_walk_actor_graphic(@actor, 108, 60)
    self.contents.draw_text(y_r, 32 * 1, 92, 32, "武器")
   
    self.contents.draw_text(y_r, 32 * 2, 92, 32, "盾牌")
    self.contents.draw_text(y_r, 32 * 3, 92, 32, "头盔")
    self.contents.draw_text(y_r, 32 * 4, 92, 32, "铠甲")
    self.contents.draw_text(y_r, 32 * 5, 92, 32, "鞋")

    self.contents.font.size = 18
    draw_item_name(@data[0], 48, 32 * 1)
    draw_item_name(@data[1], 48, 32 * 2)
    draw_item_name(@data[2], 48, 32 * 3)
    draw_item_name(@data[3], 48, 32 * 4)
    draw_item_name(@data[4], 48, 32 * 5)
    draw_actor_level(@actor, 4, 252)
  end
  #--------------------------------------------------------------------------
  # ● 刷新帮助文本
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(make_description(self.item))

  # 更新光标
#  def update_cursor_rect
#    self.cursor_rect.set(0, @index * 28+2, 176, 28)
end

  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    super
    # 可以移动光标的情况下
    if self.active and @item_max > 0 and @index >= 0
      # 方向键下被按下的情况下
      if Input.repeat?(Input::DOWN)
        # 列数不是 1 并且不与方向键下的按下状态重复的情况、
        # 或光标位置在(项目数-列数)之前的情况下
        if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
           @index < @item_max - @column_max
          # 光标向下移动
          $game_system.se_play($data_system.cursor_se)
          @index = (@index + @column_max) % @item_max
        end
      end
      # 方向键上被按下的情况下
      if Input.repeat?(Input::UP)
        # 列数不是 1 并且不与方向键下的按下状态重复的情况、
        # 或光标位置在列之后的情况下
        if (@column_max == 1 and Input.trigger?(Input::UP)) or
           @index >= @column_max
          # 光标向上移动
          $game_system.se_play($data_system.cursor_se)
          @index = (@index - @column_max + @item_max) % @item_max
        end
      end
      # 方向键右被按下的情况下
      if Input.repeat?(Input::RIGHT)
        # 列数为 2 以上并且、光标位置在(项目数 - 1)之前的情况下
        if @column_max >= 2 and @index < @item_max - 1
          # 光标向右移动
          $game_system.se_play($data_system.cursor_se)
          @index += 1
        end
      end
      # 方向键左被按下的情况下
      if Input.repeat?(Input::LEFT)
        # 列数为 2 以上并且、光标位置在 0 之后的情况下
        if @column_max >= 2 and @index > 0
          # 光标向左移动
          $game_system.se_play($data_system.cursor_se)
          @index -= 1
        end
      end
      # R 键被按下的情况下
      if Input.repeat?(Input::R)
        # 显示的最后行在数据中最后行上方的情况下
        if self.top_row + (self.page_row_max -1) < (self.row_max -1)
          # 光标向后移动一页
          $game_system.se_play($data_system.cursor_se)
          @index = [@index + self.page_item_max, @item_max -1].min
          self.top_row += self.page_row_max
        end
      end
      # L 键被按下的情况下
      if Input.repeat?(Input::L)
        # 显示的开头行在位置 0 之后的情况下
        if self.top_row > 0
          # 光标向前移动一页
          $game_system.se_play($data_system.cursor_se)
          @index = [@index - self.page_item_max, 0].max
          self.top_row -= self.page_row_max
        end
      end
    end
    # 刷新帮助文本 (update_help 定义了继承目标)
    if self.active and @help_window != nil
      update_help
    end
    # 刷新光标矩形
  def update_cursor_rect
    if @index <= -2
      self.cursor_rect.empty
    elsif @index == -1
      self.cursor_rect.set(0, 0, self.width - 32, @item_max * 80)
    else
      self.cursor_rect.set(25, @index * 70+35, self.width - 314, 55)
    end
  end
end
end[/pre]
guanbaiozuihou.jpg

评分

参与人数 1星屑 +35 收起 理由
RyanBern + 35 手动认可奖励

查看全部评分

梦石
0
星屑
9716
在线时间
2775 小时
注册时间
2008-9-5
回帖
3458

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

发表于 2016-2-25 17:44:58 | 显示全部楼层
本帖最后由 cinderelmini 于 2016-2-25 17:50 编辑

给最后一个位置做了一下判定,
代码修改的地方在最后,自定义的地方在最上面的大写部分,
最后一个位置的坐标和光标大小可以自己调。
点击展开/收起
  1. class Window_Equip_right < Window_Selectable#_New
  2.   
  3.   LAST_X = 72   # 最后一项装备的x坐标
  4.   LAST_Y = 96   # 最后一项装备的y坐标
  5.   LAST_W = 64   # 最后一项装备的光标宽度
  6.   LAST_H = 64   # 最后一项装备的光标高度
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #     actor : 角色
  10.   #--------------------------------------------------------------------------
  11.   def initialize(actor)
  12.     super(120, 104, 368, 400)
  13.     self.contents = Bitmap.new(width - 32, height - 32)
  14.     @actor = actor
  15.     refresh
  16.     self.index = 0
  17.   end
  18.   #--------------------------------------------------------------------------
  19.   # ● 获取物品
  20.   #--------------------------------------------------------------------------
  21.   def item
  22.     return @data[self.index]
  23.   end

  24.   def set_actor(actor)
  25.     @actor = actor
  26.     refresh
  27.   end

  28.   #--------------------------------------------------------------------------
  29.   # ● 刷新
  30.   #--------------------------------------------------------------------------
  31.   def refresh
  32.     self.contents.clear
  33.     draw_actor_name(@actor, 145, 0)
  34.     @data = []
  35.     @data.push($data_weapons[@actor.weapon_id])
  36.     @data.push($data_armors[@actor.armor1_id])
  37.     @data.push($data_armors[@actor.armor2_id])
  38.     @data.push($data_armors[@actor.armor3_id])
  39.     @data.push($data_armors[@actor.armor4_id])
  40.     @item_max = @data.size
  41.     self.contents.font.color = system_color
  42.     y_r = 4 # 右窗口 y 坐标
  43.     self.contents.font.size = 20
  44.     draw_walk_actor_graphic(@actor, 108, 60)
  45.     self.contents.draw_text(y_r, 32 * 1, 92, 32, "武器")

  46.     self.contents.draw_text(y_r, 32 * 2, 92, 32, "盾牌")
  47.     self.contents.draw_text(y_r, 32 * 3, 92, 32, "头盔")
  48.     self.contents.draw_text(y_r, 32 * 4, 92, 32, "铠甲")
  49.     self.contents.draw_text(LAST_X + y_r, LAST_Y, 92, 32, "鞋")

  50.     self.contents.font.size = 18
  51.     draw_item_name(@data[0], 48, 32 * 1)
  52.     draw_item_name(@data[1], 48, 32 * 2)
  53.     draw_item_name(@data[2], 48, 32 * 3)
  54.     draw_item_name(@data[3], 48, 32 * 4)
  55.     draw_item_name(@data[4], LAST_X + 48, LAST_Y)
  56.     draw_actor_level(@actor, 4, 252)
  57.   end
  58.   #--------------------------------------------------------------------------
  59.   # ● 刷新帮助文本
  60.   #--------------------------------------------------------------------------
  61.   def update_help
  62.     @help_window.set_text(make_description(self.item))
  63.   end

  64.   #--------------------------------------------------------------------------
  65.   # ● 刷新画面
  66.   #--------------------------------------------------------------------------
  67.   def update
  68.     super
  69.     # 可以移动光标的情况下
  70.     if self.active and @item_max > 0 and @index >= 0
  71.       # 方向键下被按下的情况下
  72.       if Input.repeat?(Input::DOWN)
  73.         # 列数不是 1 并且不与方向键下的按下状态重复的情况、
  74.         # 或光标位置在(项目数-列数)之前的情况下
  75.         if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
  76.            @index < @item_max - @column_max
  77.           # 光标向下移动
  78.           $game_system.se_play($data_system.cursor_se)
  79.           @index = (@index + @column_max) % @item_max
  80.         end
  81.       end
  82.       # 方向键上被按下的情况下
  83.       if Input.repeat?(Input::UP)
  84.         # 列数不是 1 并且不与方向键下的按下状态重复的情况、
  85.         # 或光标位置在列之后的情况下
  86.         if (@column_max == 1 and Input.trigger?(Input::UP)) or
  87.            @index >= @column_max
  88.           # 光标向上移动
  89.           $game_system.se_play($data_system.cursor_se)
  90.           @index = (@index - @column_max + @item_max) % @item_max
  91.         end
  92.       end
  93.       # 方向键右被按下的情况下
  94.       if Input.repeat?(Input::RIGHT)
  95.         # 列数为 2 以上并且、光标位置在(项目数 - 1)之前的情况下
  96.         if @column_max >= 2 and @index < @item_max - 1
  97.           # 光标向右移动
  98.           $game_system.se_play($data_system.cursor_se)
  99.           @index += 1
  100.         end
  101.       end
  102.       # 方向键左被按下的情况下
  103.       if Input.repeat?(Input::LEFT)
  104.         # 列数为 2 以上并且、光标位置在 0 之后的情况下
  105.         if @column_max >= 2 and @index > 0
  106.           # 光标向左移动
  107.           $game_system.se_play($data_system.cursor_se)
  108.           @index -= 1
  109.         end
  110.       end
  111.       # R 键被按下的情况下
  112.       if Input.repeat?(Input::R)
  113.         # 显示的最后行在数据中最后行上方的情况下
  114.         if self.top_row + (self.page_row_max -1) < (self.row_max -1)
  115.           # 光标向后移动一页
  116.           $game_system.se_play($data_system.cursor_se)
  117.           @index = [@index + self.page_item_max, @item_max -1].min
  118.           self.top_row += self.page_row_max
  119.         end
  120.       end
  121.       # L 键被按下的情况下
  122.       if Input.repeat?(Input::L)
  123.         # 显示的开头行在位置 0 之后的情况下
  124.         if self.top_row > 0
  125.           # 光标向前移动一页
  126.           $game_system.se_play($data_system.cursor_se)
  127.           @index = [@index - self.page_item_max, 0].max
  128.           self.top_row -= self.page_row_max
  129.         end
  130.       end
  131.     end
  132.     # 刷新帮助文本 (update_help 定义了继承目标)
  133.     if self.active and @help_window != nil
  134.       update_help
  135.     end
  136.   end
  137.   #-----------------------------
  138.   # ○ 刷新光标矩形
  139.   #-----------------------------
  140.   def update_cursor_rect
  141. #    self.cursor_rect.set(0, @index * 28+2, 176, 28)
  142.     # 最后一项的情况
  143.     if @index == @item_max - 1
  144.       self.cursor_rect.set(LAST_X, LAST_Y, LAST_W, LAST_H)
  145.     # 其他情况
  146.     else
  147.       if @index <= -2
  148.         self.cursor_rect.empty
  149.       elsif @index == -1
  150.         self.cursor_rect.set(0, 0, self.width - 32, @item_max * 80)
  151.       else
  152.         self.cursor_rect.set(25, @index * 70+35, self.width - 314, 55)
  153.       end
  154.     end
  155.   end
  156.   
  157. end
复制代码

点评

PS:不要把一个方法放在另一个方法里面………………  发表于 2016-2-25 17:51

评分

参与人数 1梦石 +1 收起 理由
RyanBern + 1 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
7296
在线时间
1244 小时
注册时间
2015-8-15
回帖
473
 楼主| 发表于 2016-2-25 18:47:04 | 显示全部楼层
cinderelmini 发表于 2016-2-25 17:44
给最后一个位置做了一下判定,
代码修改的地方在最后,自定义的地方在最上面的大写部分,
最后一个位置的坐 ...

太有魅力了,
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部