设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2533|回复: 2
打印 上一主题 下一主题

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

[复制链接]

Lv4.逐梦者

梦石
0
星屑
7559
在线时间
1315 小时
注册时间
2015-8-15
帖子
747
跳转到指定楼层
1
发表于 2016-2-25 09:31:36 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
RUBY 代码复制
  1. class Window_Equip_right < Window_Selectable#_New
  2.   #--------------------------------------------------------------------------
  3.   # ● 初始化对像
  4.   #     actor : 角色
  5.   #--------------------------------------------------------------------------
  6.   def initialize(actor)
  7.     super(120, 104, 368, 400)
  8.     self.contents = Bitmap.new(width - 32, height - 32)
  9.     @actor = actor
  10.     refresh
  11.     self.index = 0
  12.   end
  13.   #--------------------------------------------------------------------------
  14.   # ● 获取物品
  15.   #--------------------------------------------------------------------------
  16.   def item
  17.     return @data[self.index]
  18.   end
  19.  
  20.   def set_actor(actor)
  21.     @actor = actor
  22.     refresh
  23.   end
  24.  
  25.   #--------------------------------------------------------------------------
  26.   # ● 刷新
  27.   #--------------------------------------------------------------------------
  28.   def refresh
  29.     self.contents.clear
  30.     draw_actor_name(@actor, 145, 0)
  31.     @data = []
  32.     @data.push($data_weapons[@actor.weapon_id])
  33.     @data.push($data_armors[@actor.armor1_id])
  34.     @data.push($data_armors[@actor.armor2_id])
  35.     @data.push($data_armors[@actor.armor3_id])
  36.     @data.push($data_armors[@actor.armor4_id])
  37.     @item_max = @data.size
  38.     self.contents.font.color = system_color
  39.     y_r = 4 # 右窗口 y 坐标
  40.     self.contents.font.size = 20
  41.     draw_walk_actor_graphic(@actor, 108, 60)
  42.     self.contents.draw_text(y_r, 32 * 1, 92, 32, "武器")
  43.  
  44.     self.contents.draw_text(y_r, 32 * 2, 92, 32, "盾牌")
  45.     self.contents.draw_text(y_r, 32 * 3, 92, 32, "头盔")
  46.     self.contents.draw_text(y_r, 32 * 4, 92, 32, "铠甲")
  47.     self.contents.draw_text(y_r, 32 * 5, 92, 32, "鞋")
  48.  
  49.     self.contents.font.size = 18
  50.     draw_item_name(@data[0], 48, 32 * 1)
  51.     draw_item_name(@data[1], 48, 32 * 2)
  52.     draw_item_name(@data[2], 48, 32 * 3)
  53.     draw_item_name(@data[3], 48, 32 * 4)
  54.     draw_item_name(@data[4], 48, 32 * 5)
  55.     draw_actor_level(@actor, 4, 252)
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # ● 刷新帮助文本
  59.   #--------------------------------------------------------------------------
  60.   def update_help
  61.     @help_window.set_text(make_description(self.item))
  62.  
  63.   # 更新光标
  64. #  def update_cursor_rect
  65. #    self.cursor_rect.set(0, @index * 28+2, 176, 28)
  66. end
  67.  
  68.   #--------------------------------------------------------------------------
  69.   # ● 刷新画面
  70.   #--------------------------------------------------------------------------
  71.   def update
  72.     super
  73.     # 可以移动光标的情况下
  74.     if self.active and @item_max > 0 and @index >= 0
  75.       # 方向键下被按下的情况下
  76.       if Input.repeat?(Input::DOWN)
  77.         # 列数不是 1 并且不与方向键下的按下状态重复的情况、
  78.         # 或光标位置在(项目数-列数)之前的情况下
  79.         if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
  80.            @index < @item_max - @column_max
  81.           # 光标向下移动
  82.           $game_system.se_play($data_system.cursor_se)
  83.           @index = (@index + @column_max) % @item_max
  84.         end
  85.       end
  86.       # 方向键上被按下的情况下
  87.       if Input.repeat?(Input::UP)
  88.         # 列数不是 1 并且不与方向键下的按下状态重复的情况、
  89.         # 或光标位置在列之后的情况下
  90.         if (@column_max == 1 and Input.trigger?(Input::UP)) or
  91.            @index >= @column_max
  92.           # 光标向上移动
  93.           $game_system.se_play($data_system.cursor_se)
  94.           @index = (@index - @column_max + @item_max) % @item_max
  95.         end
  96.       end
  97.       # 方向键右被按下的情况下
  98.       if Input.repeat?(Input::RIGHT)
  99.         # 列数为 2 以上并且、光标位置在(项目数 - 1)之前的情况下
  100.         if @column_max >= 2 and @index < @item_max - 1
  101.           # 光标向右移动
  102.           $game_system.se_play($data_system.cursor_se)
  103.           @index += 1
  104.         end
  105.       end
  106.       # 方向键左被按下的情况下
  107.       if Input.repeat?(Input::LEFT)
  108.         # 列数为 2 以上并且、光标位置在 0 之后的情况下
  109.         if @column_max >= 2 and @index > 0
  110.           # 光标向左移动
  111.           $game_system.se_play($data_system.cursor_se)
  112.           @index -= 1
  113.         end
  114.       end
  115.       # R 键被按下的情况下
  116.       if Input.repeat?(Input::R)
  117.         # 显示的最后行在数据中最后行上方的情况下
  118.         if self.top_row + (self.page_row_max -1) < (self.row_max -1)
  119.           # 光标向后移动一页
  120.           $game_system.se_play($data_system.cursor_se)
  121.           @index = [@index + self.page_item_max, @item_max -1].min
  122.           self.top_row += self.page_row_max
  123.         end
  124.       end
  125.       # L 键被按下的情况下
  126.       if Input.repeat?(Input::L)
  127.         # 显示的开头行在位置 0 之后的情况下
  128.         if self.top_row > 0
  129.           # 光标向前移动一页
  130.           $game_system.se_play($data_system.cursor_se)
  131.           @index = [@index - self.page_item_max, 0].max
  132.           self.top_row -= self.page_row_max
  133.         end
  134.       end
  135.     end
  136.     # 刷新帮助文本 (update_help 定义了继承目标)
  137.     if self.active and @help_window != nil
  138.       update_help
  139.     end
  140.     # 刷新光标矩形
  141.   def update_cursor_rect
  142.     if @index <= -2
  143.       self.cursor_rect.empty
  144.     elsif @index == -1
  145.       self.cursor_rect.set(0, 0, self.width - 32, @item_max * 80)
  146.     else
  147.       self.cursor_rect.set(25, @index * 70+35, self.width - 314, 55)
  148.     end
  149.   end
  150. end
  151. end

guanbaiozuihou.jpg (186.44 KB, 下载次数: 4)

guanbaiozuihou.jpg

评分

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

查看全部评分

Lv4.逐梦者

「Pemercyia」


Urhurrenna

梦石
0
星屑
9397
在线时间
2748 小时
注册时间
2008-9-5
帖子
3543

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

2
发表于 2016-2-25 17:44:58 | 只看该作者
本帖最后由 cinderelmini 于 2016-2-25 17:50 编辑

给最后一个位置做了一下判定,
代码修改的地方在最后,自定义的地方在最上面的大写部分,
最后一个位置的坐标和光标大小可以自己调。

点评

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

评分

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

查看全部评分

回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
7559
在线时间
1315 小时
注册时间
2015-8-15
帖子
747
3
 楼主| 发表于 2016-2-25 18:47:04 | 只看该作者
cinderelmini 发表于 2016-2-25 17:44
给最后一个位置做了一下判定,
代码修改的地方在最后,自定义的地方在最上面的大写部分,
最后一个位置的坐 ...

太有魅力了,
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-22 17:21

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表