Auteur: Yukihiro matsumoto
#============================================
# ¡ Sprite_Timer
#----------------------------------------------
# @ƒ^ƒCƒ}[•Ž¦—p‚̃Xƒvƒ‰ƒCƒg‚Å‚·B$game_system ‚ðŠÄŽ‹‚µAƒXƒvƒ‰ƒCƒg‚Ìó‘Ô‚ð
# Ž©“®“I‚ɕω»‚³‚¹‚Ü‚·B
#============================================
class Sprite_Timer < Sprite
#------------------------------------------
# œ ƒIƒuƒWƒFƒNƒg‰Šú‰»
#------------------------------------------
def initialize
super
self.bitmap = Bitmap.new(88, 48)
self.bitmap.font.name = "Arial"
self.bitmap.font.size = 32
self.x = 640 - self.bitmap.width
self.y = 0
self.z = 500
update
end
#------------------------------------------
# œ ‰ð•ú
#------------------------------------------
def dispose
if self.bitmap != nil
self.bitmap.dispose
end
super
end
#------------------------------------------
# œ ƒtƒŒ[ƒ€XV
#------------------------------------------
def update
super
# ƒ^ƒCƒ}[ì“®’†‚È‚ç‰ÂŽ‹‚ÉÝ’è
self.visible = $game_system.timer_working
# ƒ^ƒCƒ}[‚ðÄ•`‰æ‚·‚é•K—v‚ª‚ ‚éê‡
if $game_system.timer / Graphics.frame_rate != @total_sec
# ƒEƒBƒ“ƒhƒE“à—e‚ðƒNƒŠƒA
self.bitmap.clear
# ƒg[ƒ^ƒ‹•b”‚ðŒvŽZ
@total_sec = $game_system.timer / Graphics.frame_rate
# ƒ^ƒCƒ}[•Ž¦—p‚Ì•¶Žš—ñ‚ðì¬
min = @total_sec / 60
sec = @total_sec % 60
text = sprintf("%02d:%02d", min, sec)
# ƒ^ƒCƒ}[‚ð•`‰æ
self.bitmap.font.color.set(255, 255, 255)
self.bitmap.draw_text(self.bitmap.rect, text, 1)
end
end
end |
|