Project1

标题: 計時器前顯示icon [打印本页]

作者: QQ蚊子湯    时间: 2016-10-29 09:45
标题: 計時器前顯示icon
有想過draw_icon什麼的,不過...計時器不是窗口吧{:2_254:}

作者: RaidenInfinity    时间: 2016-10-29 10:02
本帖最后由 RaidenInfinity 于 2016-10-29 10:23 编辑

加这个就可以在Sprite_Timer里面调用draw_icon了。

RUBY 代码复制
  1. class Sprite_Timer < Sprite
  2.  
  3.   def draw_icon(icon_index, x, y, enabled = true)
  4.     bitmap = Cache.system("Iconset")
  5.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  6.     self.bitmap.blt(x, y, bitmap, rect, enabled ? 255 : 160)
  7.   end
  8.  
  9. end


讲真,我感觉Window_Base里面的一些功能嵌进去Bitmap类可能会方便些。(draw_icon, draw_gauge之类的)
把contents换成self就得。

RUBY 代码复制
  1. class Bitmap
  2.  
  3.   def draw_icon(icon_index, x, y, enabled = true)
  4.     bitmap = Cache.system("Iconset")
  5.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  6.     self.blt(x, y, bitmap, rect, enabled ? 255 : 160)
  7.   end
  8.  
  9. end

作者: QQ蚊子湯    时间: 2016-10-29 13:53
自己嘗試了一下,雖然可以調用但是沒有效果
應該是我姿勢有誤{:2_271:}

RUBY 代码复制
  1. class Sprite_Timer < Sprite
  2.   def create_bitmap
  3.     self.bitmap = Bitmap.new(96, 48)
  4.     self.bitmap.font.size = 32
  5.     self.bitmap.font.color.set(255, 255, 255)
  6.     draw_icon(20,90,48)
  7.   end



作者: QQ蚊子湯    时间: 2016-10-29 16:50

成功了! 非常感謝版主樣和蹭得累桑

題外話問一下重繪ICON會很多餘嗎?




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