| 赞 | 46 |
| VIP | |
| 好人卡 | |
| 积分 | 97 |
| 经验 | |
| 最后登录 | 2026-6-17 |
| 在线时间 | 2775 小时 |
梦石0
星屑9716
在线时间2775 小时
注册时间2008-9-5
回帖3458
   
|
发表于 2016-2-25 17:44:58
|
显示全部楼层
本帖最后由 cinderelmini 于 2016-2-25 17:50 编辑
给最后一个位置做了一下判定,
代码修改的地方在最后,自定义的地方在最上面的大写部分,
最后一个位置的坐标和光标大小可以自己调。
点击展开/收起- class Window_Equip_right < Window_Selectable#_New
-
- LAST_X = 72 # 最后一项装备的x坐标
- LAST_Y = 96 # 最后一项装备的y坐标
- LAST_W = 64 # 最后一项装备的光标宽度
- LAST_H = 64 # 最后一项装备的光标高度
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # 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(LAST_X + y_r, LAST_Y, 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], LAST_X + 48, LAST_Y)
- draw_actor_level(@actor, 4, 252)
- end
- #--------------------------------------------------------------------------
- # ● 刷新帮助文本
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(make_description(self.item))
- 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
- end
- #-----------------------------
- # ○ 刷新光标矩形
- #-----------------------------
- def update_cursor_rect
- # self.cursor_rect.set(0, @index * 28+2, 176, 28)
- # 最后一项的情况
- if @index == @item_max - 1
- self.cursor_rect.set(LAST_X, LAST_Y, LAST_W, LAST_H)
- # 其他情况
- else
- 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
复制代码 |
评分
-
查看全部评分
|