查看: 2663|回复: 2

[已经过期] 关于光标换行的问题

[复制链接]
梦石
0
星屑
1090
在线时间
324 小时
注册时间
2017-1-24
回帖
105

开拓者

发表于 2017-2-18 23:25:43 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 戴迪 于 2017-2-19 00:54 编辑

自己调了装备界面item的列数,改成5行,然后在最后添加了一个移动光标矩形的间距,但是好像不能换行阿- -
  1. #==============================================================================
  2. # ■ Window_EquipItem
  3. #------------------------------------------------------------------------------
  4. #  装备画面、显示浏览变更装备的候补物品的窗口。
  5. #==============================================================================

  6. class Window_EquipItem < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #     actor      : 角色
  10.   #     equip_type : 装备部位 (0~3)
  11.   #--------------------------------------------------------------------------
  12.   def initialize(actor, equip_type)
  13.     super(160, 256, 640, 224)
  14.     @actor = actor
  15.     @equip_type = equip_type
  16.     @column_max = 5
  17.     refresh
  18.     self.active = false
  19.     self.index = -1
  20.   end
  21.   #--------------------------------------------------------------------------
  22.   # ● 获取物品
  23.   #--------------------------------------------------------------------------
  24.   def item
  25.     return @data[self.index]
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # ● 刷新
  29.   #--------------------------------------------------------------------------
  30.   def refresh
  31.     if self.contents != nil
  32.       self.contents.dispose
  33.       self.contents = nil
  34.     end
  35.     @data = []
  36.     # 添加可以装备的武器
  37.     if @equip_type == 0
  38.       weapon_set = $data_classes[@actor.class_id].weapon_set
  39.       for i in 1...$data_weapons.size
  40.         if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
  41.           @data.push($data_weapons[i])
  42.         end
  43.       end
  44.     end
  45.     # 添加可以装备的防具
  46.     if @equip_type != 0
  47.       armor_set = $data_classes[@actor.class_id].armor_set
  48.       for i in 1...$data_armors.size
  49.         if $game_party.armor_number(i) > 0 and armor_set.include?(i)
  50.           if $data_armors[i].kind == @equip_type-1
  51.             @data.push($data_armors[i])
  52.           end
  53.         end
  54.       end
  55.     end
  56.     # 添加空白
  57.     @data.push(nil)
  58.     # 生成位图、描绘全部项目
  59.     @item_max = @data.size
  60.     self.contents = Bitmap.new(width - 32, row_max * 32)
  61.     for i in 0...@item_max-1
  62.       draw_item(i)
  63.     end
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ● 项目的描绘
  67.   #     index : 项目符号
  68.   #--------------------------------------------------------------------------
  69.   def draw_item(index)
  70.     item = @data[index]
  71.     x = 4 + index % 5 * (32)
  72.     y = index / 5 * 32
  73.     case item
  74.     when RPG::Weapon
  75.       number = $game_party.weapon_number(item.id)
  76.     when RPG::Armor
  77.       number = $game_party.armor_number(item.id)
  78.     end
  79.     bitmap = RPG::Cache.icon(item.icon_name)
  80.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  81.     self.contents.font.color = normal_color
  82. #    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  83. #   self.contents.draw_text(x +32 , y, 16, 32, ":", 1)
  84.     self.contents.draw_text(x  , y, 24, 32, number.to_s, 2)
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # ● 刷新帮助文本
  88.   #--------------------------------------------------------------------------
  89.   def update_help
  90.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # ● 刷新光标矩形
  94.   #--------------------------------------------------------------------------
  95.   def update_cursor_rect
  96.       self.cursor_rect.set(@index * 32,0 , 32, 32)
  97.     end
  98. end
复制代码

==============(第一次更新)===================================
后来自己又弄了下,成了这样,不知道怎么弄才能把光标移动到第25个装备上时.就不能再往下移动!不然多出来一个位置不美观
  1. #==============================================================================
  2. # ■ Window_EquipItem
  3. #------------------------------------------------------------------------------
  4. #  装备画面、显示浏览变更装备的候补物品的窗口。
  5. #==============================================================================

  6. class Window_EquipItem < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #     actor      : 角色
  10.   #     equip_type : 装备部位 (0~3)
  11.   #--------------------------------------------------------------------------
  12.   def initialize(actor, equip_type)
  13.     super(160, 256, 640, 224)
  14.     @actor = actor
  15.     @equip_type = equip_type
  16.     @column_max = 5
  17.     refresh
  18.     self.active = false
  19.     self.index = -1
  20.   end
  21.   #--------------------------------------------------------------------------
  22.   # ● 获取物品
  23.   #--------------------------------------------------------------------------
  24.   def item
  25.     return @data[self.index]
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # ● 刷新
  29.   #--------------------------------------------------------------------------
  30.   def refresh
  31.     if self.contents != nil
  32.       self.contents.dispose
  33.       self.contents = nil
  34.     end
  35.     @data = []
  36.     # 添加可以装备的武器
  37.     if @equip_type == 0
  38.       weapon_set = $data_classes[@actor.class_id].weapon_set
  39.       for i in 1...50
  40.         if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
  41.           @data.push($data_weapons[i])
  42.         end
  43.       end
  44.     end
  45.     # 添加可以装备的防具
  46.     if @equip_type != 0
  47.       armor_set = $data_classes[@actor.class_id].armor_set
  48.       for i in 1...$data_armors.size
  49.         if $game_party.armor_number(i) > 0 and armor_set.include?(i)
  50.           if $data_armors[i].kind == @equip_type-1
  51.             @data.push($data_armors[i])
  52.           end
  53.         end
  54.       end
  55.     end
  56.     # 添加空白
  57.     @data.push(nil)
  58.     # 生成位图、描绘全部项目
  59.     @item_max = @data.size
  60.     self.contents = Bitmap.new(width - 32, row_max * 32)
  61.     for i in 0...@item_max-1
  62.       draw_item(i)
  63.     end
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ● 项目的描绘
  67.   #     index : 项目符号
  68.   #--------------------------------------------------------------------------
  69.   def draw_item(index)
  70.     item = @data[index]
  71.     x = 4 + index % 5 * (32)
  72.     y = index / 5 * 32
  73.     case item
  74.     when RPG::Weapon
  75.       number = $game_party.weapon_number(item.id)
  76.     when RPG::Armor
  77.       number = $game_party.armor_number(item.id)
  78.     end
  79.     bitmap = RPG::Cache.icon(item.icon_name)
  80.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  81.     self.contents.font.color = normal_color
  82. #    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  83. #   self.contents.draw_text(x +32 , y, 16, 32, ":", 1)
  84.     self.contents.draw_text(x  , y, 24, 32, number.to_s, 2)
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # ● 刷新帮助文本
  88.   #--------------------------------------------------------------------------
  89.   def update_help
  90.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # ● 刷新光标矩形
  94.   #--------------------------------------------------------------------------
  95.   def update_cursor_rect
  96.     self.cursor_rect.set(@index * 32,0 , 32, 32)
  97.     if @index > 4
  98.       self.cursor_rect.set( (@index - 5 )* 32,32 , 32, 32)
  99.     end
  100.     if @index > 9
  101.       self.cursor_rect.set( (@index - 10 )* 32,64 , 32, 32)
  102.     end
  103.     if @index > 14
  104.       self.cursor_rect.set( (@index - 15 )* 32,96 , 32, 32)
  105.     end
  106.     if @index > 19
  107.       self.cursor_rect.set( (@index - 20 )* 32,128 , 32, 32)
  108.     end
  109.   end
  110. end
复制代码

20170218232057.png
QQ截图20170219005008.png
梦石
0
星屑
125
在线时间
171 小时
注册时间
2014-4-14
回帖
135
发表于 2017-2-19 12:48:23 | 显示全部楼层
  1. #==============================================================================
  2. # ■ Window_EquipItem
  3. #------------------------------------------------------------------------------
  4. #  装备画面、显示浏览变更装备的候补物品的窗口。
  5. #==============================================================================

  6. class Window_EquipItem < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #     actor      : 角色
  10.   #     equip_type : 装备部位 (0~3)
  11.   #--------------------------------------------------------------------------
  12.   def initialize(actor, equip_type)
  13.     super(160, 256, 640, 224)
  14.     @actor = actor
  15.     @equip_type = equip_type
  16.     @column_max = 5
  17.     refresh
  18.     self.active = false
  19.     self.index = -1
  20.   end
  21.   #--------------------------------------------------------------------------
  22.   # ● 获取物品
  23.   #--------------------------------------------------------------------------
  24.   def item
  25.     return @data[self.index]
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # ● 刷新
  29.   #--------------------------------------------------------------------------
  30.   def refresh
  31.     if self.contents != nil
  32.       self.contents.dispose
  33.       self.contents = nil
  34.     end
  35.     @data = []
  36.     # 添加可以装备的武器
  37.     if @equip_type == 0
  38.       weapon_set = $data_classes[@actor.class_id].weapon_set
  39.       for i in 1...50
  40.         if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
  41.           @data.push($data_weapons[i])
  42.         end
  43.       end
  44.     end
  45.     # 添加可以装备的防具
  46.     if @equip_type != 0
  47.       armor_set = $data_classes[@actor.class_id].armor_set
  48.       for i in 1...$data_armors.size
  49.         if $game_party.armor_number(i) > 0 and armor_set.include?(i)
  50.           if $data_armors[i].kind == @equip_type-1
  51.             @data.push($data_armors[i])
  52.           end
  53.         end
  54.       end
  55.     end
  56.     # 添加空白
  57.     @data.push(nil)
  58.     # 生成位图、描绘全部项目
  59.     @item_max = @data.size
  60.     self.contents = Bitmap.new(width - 32, row_max * 32)
  61.     for i in 0...@item_max-1
  62.       draw_item(i)
  63.     end
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ● 项目的描绘
  67.   #     index : 项目符号
  68.   #--------------------------------------------------------------------------
  69.   def draw_item(index)
  70.     item = @data[index]
  71.     x = 4 + index % 5 * (32)
  72.     y = index / 5 * 32
  73.     case item
  74.     when RPG::Weapon
  75.       number = $game_party.weapon_number(item.id)
  76.     when RPG::Armor
  77.       number = $game_party.armor_number(item.id)
  78.     end
  79.     bitmap = RPG::Cache.icon(item.icon_name)
  80.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  81.     self.contents.font.color = normal_color
  82.     #self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  83.     #self.contents.draw_text(x +32 , y, 16, 32, ":", 1)
  84.     self.contents.draw_text(x  , y, 24, 32, number.to_s, 2)
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # ● 刷新帮助文本
  88.   #--------------------------------------------------------------------------
  89.   def update_help
  90.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # ● 刷新光标矩形
  94.   #--------------------------------------------------------------------------
  95.   def update_cursor_rect
  96.     self.cursor_rect.set(@index * 32,0 , 32, 32)
  97.     if @index == -1
  98.          self.cursor_rect.set(0,0, 0, 0)
  99.     elsif @index > 4 and @index <= 9
  100.      self.cursor_rect.set( (@index - 5 )* 32,32 , 32, 32)
  101.    elsif @index > 9 and @index <= 14
  102.       self.cursor_rect.set( (@index- 10 )* 32,64 , 32, 32)
  103.     elsif @index > 14 and @index <= 19
  104.       self.cursor_rect.set( (@index- 15 )* 32,96 , 32, 32)
  105.     elsif @index > 19 and @index <= 24
  106.       self.cursor_rect.set( (@index- 20 )* 32,128 , 32, 32)
  107.     elsif @index > 24
  108.       self.cursor_rect.set( 24 * 32,128 , 32, 32)
  109.       @index -= 1
  110.       end
  111.   end
  112. end
复制代码

评分

参与人数 1星屑 +90 收起 理由
RyanBern + 90 塞糖

查看全部评分

Vanyogin
回复 1 0

使用道具 举报

梦石
0
星屑
1090
在线时间
324 小时
注册时间
2017-1-24
回帖
105

开拓者

 楼主| 发表于 2017-2-19 13:16:53 | 显示全部楼层
2357691704 发表于 2017-2-19 12:48
#==============================================================================
# ■ Window_EquipIte ...


谢谢啊!虽然还没试验过,但单看脚本好像没什么问题了。有时间就弄弄
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部