#==============================================================================
# ** Sprite_Timer
#------------------------------------------------------------------------------
# This sprite is used to display the timer.It observes the $game_system
# class and automatically changes sprite conditions.
#==============================================================================
class Sprite_Timer < Sprite
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super
Graphics.frame_rate = 0.01
self.bitmap = Bitmap.new(132, 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
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
if self.bitmap != nil
self.bitmap.dispose
end
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
self.visible = $game_system.timer_working
if $game_system.timer.to_f / 40.0 != @total_sec
self.bitmap.clear
@total_sec = $game_system.timer.to_f / 40.0
min = @total_sec / 60
sec = @total_sec % 60
mil = (@total_sec.to_f * 60) % 60
text = sprintf("%02d:%02d:%02d", min, sec, mil)
self.bitmap.font.color.set(255, 255, 255)
self.bitmap.draw_text(self.bitmap.rect, text, 1)
end
end
end