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了。
class Sprite_Timer < Sprite
def draw_icon(icon_index, x, y, enabled = true)
bitmap = Cache.system("Iconset")
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
self.bitmap.blt(x, y, bitmap, rect, enabled ? 255 : 160)
end
end
class Sprite_Timer < Sprite
def draw_icon(icon_index, x, y, enabled = true)
bitmap = Cache.system("Iconset")
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
self.bitmap.blt(x, y, bitmap, rect, enabled ? 255 : 160)
end
end
讲真,我感觉Window_Base里面的一些功能嵌进去Bitmap类可能会方便些。(draw_icon, draw_gauge之类的)
把contents换成self就得。
class Bitmap
def draw_icon(icon_index, x, y, enabled = true)
bitmap = Cache.system("Iconset")
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
self.blt(x, y, bitmap, rect, enabled ? 255 : 160)
end
end
class Bitmap
def draw_icon(icon_index, x, y, enabled = true)
bitmap = Cache.system("Iconset")
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
self.blt(x, y, bitmap, rect, enabled ? 255 : 160)
end
end
作者: QQ蚊子湯 时间: 2016-10-29 13:53
自己嘗試了一下,雖然可以調用但是沒有效果
應該是我姿勢有誤{:2_271:}
class Sprite_Timer < Sprite
def create_bitmap
self.bitmap = Bitmap.new(96, 48)
self.bitmap.font.size = 32
self.bitmap.font.color.set(255, 255, 255)
draw_icon(20,90,48)
end
class Sprite_Timer < Sprite
def create_bitmap
self.bitmap = Bitmap.new(96, 48)
self.bitmap.font.size = 32
self.bitmap.font.color.set(255, 255, 255)
draw_icon(20,90,48)
end
作者: QQ蚊子湯 时间: 2016-10-29 16:50
成功了! 非常感謝版主樣和蹭得累桑
題外話問一下重繪ICON會很多餘嗎?
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |