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

Project1

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

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

[复制链接]

Lv3.寻梦者

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

开拓者

跳转到指定楼层
1
发表于 2017-2-18 23:25:43 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

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

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

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

20170218232057.png (68.56 KB, 下载次数: 2)

20170218232057.png

QQ截图20170219005008.png (72.43 KB, 下载次数: 4)

QQ截图20170219005008.png

Lv1.梦旅人

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

评分

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

查看全部评分

Vanyogin
回复 支持 1 反对 0

使用道具 举报

Lv3.寻梦者

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

开拓者

3
 楼主| 发表于 2017-2-19 13:16:53 | 只看该作者
2357691704 发表于 2017-2-19 12:48
#==============================================================================
# ■ Window_EquipIte ...


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

使用道具 举报

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

本版积分规则

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

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

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

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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