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