这种东西呢,彩虹神剑里应该有相关的用法。原理是把一个数拆成几个数字,然后拼合bitmap。不知道楼主的脚本水平如何,总之给一个提示。
1. 准备一个数字图片,比如说160x32的0-9挨个排好,每个数字是16x32大小。命名为 sp.png,放在Picture下。就像这样~
2. 把这个脚本插到 main 前,应该能看到效果~
class Sprite_SP def initialize(fn = 'sp') @bitmap = RPG::Cache.picture(fn) @sprite = RPG::Sprite.new # @sprite.z = 1 end def show(number, x, y, fn = nil) @bitmap = RPG::Cache.picture(fn) if fn nums = number.to_s.scan(/\d/).collect{|i| i.to_i} bitmap = Bitmap.new(nums.size * 16, 32) nums.each_index do |i| rect = Rect.new(nums[i] * 16, 0, 16, 32) bitmap.blt(i * 16, 0, @bitmap, rect) end @sprite.bitmap = bitmap @sprite.visible = true @sprite.x = x @sprite.y = y end def hide @sprite.visible = false end def dispose @sprite.dispose @bitmap.dispose end end $sp_sprite = Sprite_SP.new $sp_sprite.show(100, 0, 0) 40.times{Graphics.update} $sp_sprite.hide $sp_sprite.dispose
class Sprite_SP
def initialize(fn = 'sp')
@bitmap = RPG::Cache.picture(fn)
@sprite = RPG::Sprite.new
# @sprite.z = 1
end
def show(number, x, y, fn = nil)
@bitmap = RPG::Cache.picture(fn) if fn
nums = number.to_s.scan(/\d/).collect{|i| i.to_i}
bitmap = Bitmap.new(nums.size * 16, 32)
nums.each_index do |i|
rect = Rect.new(nums[i] * 16, 0, 16, 32)
bitmap.blt(i * 16, 0, @bitmap, rect)
end
@sprite.bitmap = bitmap
@sprite.visible = true
@sprite.x = x
@sprite.y = y
end
def hide
@sprite.visible = false
end
def dispose
@sprite.dispose
@bitmap.dispose
end
end
$sp_sprite = Sprite_SP.new
$sp_sprite.show(100, 0, 0)
40.times{Graphics.update}
$sp_sprite.hide
$sp_sprite.dispose
|