Project1

标题: 关于装备栏操作及显示问题。 [打印本页]

作者: 冥域圣君    时间: 2023-4-9 22:26
标题: 关于装备栏操作及显示问题。
扩展装备种类减小装备大小以后,下边的添加的装备种类和装备都不能显示了这怎么办[index]
  1. #==============================================================================
  2. # ■ Window_EquipRight
  3. #------------------------------------------------------------------------------
  4. #  装备画面、显示角色现在装备的物品的窗口。
  5. #==============================================================================

  6. class Window_EquipRight < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #     actor : 角色
  10.   #--------------------------------------------------------------------------
  11.   def initialize(actor)
  12.     super(30, 230, 308, 155)
  13.     self.contents = Bitmap.new(width - 32, height - 32)
  14.     self.opacity = 0
  15.     @actor = actor
  16.     refresh
  17.     self.index = 0
  18.   end
  19.   #--------------------------------------------------------------------------
  20.   # ● 获取物品
  21.   #--------------------------------------------------------------------------
  22.   def item
  23.     return @data[self.index]
  24.   end
  25.   #--------------------------------------------------------------------------
  26.   # ● 刷新
  27.   #--------------------------------------------------------------------------
  28.   def refresh
  29.     self.contents.clear
  30.     @data = []
  31.     @data.push($data_weapons[@actor.weapon_id])
  32.     @data.push($data_armors[@actor.armor1_id])
  33.     @data.push($data_armors[@actor.armor2_id])
  34.     @data.push($data_armors[@actor.armor3_id])
  35.     @data.push($data_armors[@actor.armor4_id])
  36.     @data.push($data_armors[@actor.armor5_id])
  37.     @data.push($data_armors[@actor.armor6_id])
  38.     @data.push($data_armors[@actor.armor7_id])
  39.     @item_max = @data.size
  40.     self.contents.font.color = system_color
  41.     self.contents.font.size = 25
  42.     a = 32
  43.     b = 0   
  44.     self.contents.draw_text(4, a * 0, 92, a, $data_system.words.weapon)
  45.     self.contents.draw_text(4, a * 1, 92, a, $data_system.words.armor1)
  46.     self.contents.draw_text(4, a * 2, 92, a, $data_system.words.armor2)
  47.     self.contents.draw_text(4, a * 3, 92, a, $data_system.words.armor3)
  48.     self.contents.draw_text(5, a * 4, 92, a, $data_system.words.armor4)
  49.     self.contents.draw_text(5, a * 5, 92, a, "马匹")
  50.     self.contents.draw_text(5, a * 6, 92, a, "石")
  51.     self.contents.draw_text(5, a * 7, 92, a, "玉")
  52.     draw_item_name(@data[0], 92, a * 0)
  53.     draw_item_name(@data[1], 92, a * 1)
  54.     draw_item_name(@data[2], 92, a * 2)
  55.     draw_item_name(@data[3], 92, a * 3)
  56.     draw_item_name(@data[4], 92, a * 4)
  57.     draw_item_name(@data[5], 92, a * 5)
  58.     draw_item_name(@data[6], 92, a * 6)
  59.     draw_item_name(@data[7], 92, a * 7)
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # ● 刷新帮助文本
  63.   #--------------------------------------------------------------------------
  64.   def update_help
  65.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  66.   end
  67. end
复制代码



QQ截图20230409221842.png (7.13 KB, 下载次数: 9)

QQ截图20230409221842.png

作者: 金芒芒    时间: 2023-4-10 09:25
本帖最后由 金芒芒 于 2023-4-10 16:42 编辑

super(30, 230, 308, 155)  30和230 是光标大小  308和155是显示窗口大小308是宽  155是长  
修改30 和230  是属于和大窗口部分减去间隔坐标在定位装备显示宽308和长155   说155的距离短了才没显示出添加部分没显示

12.png (83.89 KB, 下载次数: 13)

12.png

作者: 冥域圣君    时间: 2023-4-12 06:59
就是装备选项显示4种超出框外的三种按下就是不会显示了
作者: 冥域圣君    时间: 2023-4-12 07:02
rt
作者: qq634488405    时间: 2023-4-12 08:47
super(30, 230, 308, 155)
self.contents = Bitmap.new(width - 32, height - 32)
你的窗口宽度308,高度155,contents宽度276高度123
而这几句描绘文本的坐标已经超出了contents的范围了,所以不会显示
self.contents.draw_text(5, a * 4, 92, a, $data_system.words.armor4)  #5,128
self.contents.draw_text(5, a * 5, 92, a, "马匹")  #5,160
self.contents.draw_text(5, a * 6, 92, a, "石")   #5,192
self.contents.draw_text(5, a * 7, 92, a, "玉")  #5,224

因此在生成contents的时候需要修改大小,按照你现在的窗口想要显示的内容应该改为
self.contents = Bitmap.new(width - 32, 8*32)
作者: 金芒芒    时间: 2023-4-12 08:55
冥域圣君 发表于 2023-4-12 07:02
rt

那你要改窗口大小呢?还是窗口不变跟包裹一样下拉呢
作者: 纯属小虫    时间: 2023-4-12 10:23
5楼是正解,第14行 self.contents = Bitmap.new 的问题
详情可以参考商店商品列表窗口的做法,它们的 Bitmap.new 的宽高是个变量,且大小可能超过窗口大小,这样才有可能描绘窗口之外的items;当然,这里用定量 8*32 就行了




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1