Project1

标题: 有关个状态栏的小问题,请教。 [打印本页]

作者: 美丽晨露    时间: 2013-11-24 21:09
标题: 有关个状态栏的小问题,请教。
本帖最后由 美丽晨露 于 2013-11-24 22:27 编辑

RUBY 代码复制
  1. class Sprite_States_Icon < Sprite
  2.   def initialize(actor, x, y, view_area)
  3.     super(view_area)
  4.     @back = Sprite.new(view_area)
  5.     @back.bitmap = Cache.system("Statebox.png")
  6.     @back.opacity = 128
  7.     [url=home.php?mod=space&uid=95897]@actor[/url] = actor
  8.     @states = []
  9.     self.bitmap = Bitmap.new(24 * 4, 24)
  10.     self.x = x
  11.     self.y = y
  12.     @back.x = x
  13.     @back.y = y
  14.     @back.z = 200
  15.     update
  16.   end
  17.  
  18.   def update
  19.     return if @states == @actor.states
  20.     self.bitmap.clear
  21.     count = 0
  22.     @states = @actor.states
  23.     for state in @actor.states
  24.      draw_icon(state.icon_index, x + 24 * count, y)
  25.       count += 1
  26.       break if (24 * count > width - 24)
  27.     end
  28.   end
  29.  
  30.   def draw_icon(icon_index, x, y, enabled = true)
  31.     bitmap = Cache.system("Iconset")
  32.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 96)
  33.     self.bitmap.blt(0, 0, bitmap, rect, enabled ? 255 : 128)
  34.   end


这个是某一个脚本内显示状态的脚本,可是我怎么改都只能显示一个状态。
要不就是改出排列是竖着的状态显示,而且显示的状态图标也不正确。
请问要怎么修改才能达到横着最大排列四个状态,而且是显示正确的哟。


作者: 铃仙·优昙华院·因幡    时间: 2013-11-24 21:29
怎么感觉你的代码

draw_icon(state.icon_index, x + 24 * count, y)

这句会出错?
作者: 铃仙·优昙华院·因幡    时间: 2013-11-24 22:02
  1. class Sprite_States_Icon < Sprite
  2.   def initialize(actor, x, y, view_area)
  3.     super(view_area)
  4.     @back = Sprite.new(view_area)
  5.     @back.bitmap = Cache.system("Statebox.png")
  6.     @back.opacity = 128
  7.     [url=home.php?mod=space&uid=95897]@actor[/url] = actor
  8.     @states = []
  9.     self.bitmap = Bitmap.new(24 * 4, 24)
  10.     self.x = x
  11.     self.y = y
  12.     @back.x = x
  13.     @back.y = y
  14.     @back.z = 200
  15.     update
  16.   end

  17.   def update
  18.     return if @states == @actor.states
  19.     self.bitmap.clear
  20.     @states = @actor.states
  21.     x = 0
  22.     y = 0
  23.     @actor.states.each_with_index do |states, count|
  24.       draw_icon(states.icon_index, x + 24 * count, y)
  25.       break if (24 * count > width - 24)
  26.     end
  27.   end

  28.   def draw_icon(icon_index, x, y, enabled = true)
  29.     bitmap = Cache.system("Iconset")
  30.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 96)
  31.     self.bitmap.blt(x, y, bitmap, rect, enabled ? 255 : 128)
  32.   end
复制代码
未测试
作者: 美丽晨露    时间: 2013-11-24 22:13
铃仙·优昙华院·因幡 发表于 2013-11-24 22:02
未测试

谢谢,但是测试了没有发生改变的说
我附上工程,方便您修改测试吧
作者: 铃仙·优昙华院·因幡    时间: 2013-11-24 22:17
里面的 x y 自己改改
作者: 铃仙·优昙华院·因幡    时间: 2013-11-24 22:29
美丽晨露 发表于 2013-11-24 22:13
谢谢,但是测试了没有发生改变的说
我附上工程,方便您修改测试吧



替换掉我的脚本之后 , 一切正常的呀




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