#============================================================================== # ■ Game_Timer #============================================================================== class Game_Timer #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :pause #-------------------------------------------------------------------------- # ● 小数点以下の取得 #-------------------------------------------------------------------------- def count (@count - sec * Graphics.frame_rate) * 100 / Graphics.frame_rate end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update if @working && @count > 0 && !@pause @count -= 1 on_expire if @count == 0 end end end #============================================================================== # ■ Sprite_Timer #============================================================================== class Sprite_Timer < Sprite #-------------------------------------------------------------------------- # ● 転送元ビットマップの更新 #-------------------------------------------------------------------------- def update_bitmap if visible @total_sec = $game_timer.sec redraw end if $game_timer.pause @count = 20 if !@count; @count -= 1; @count = 20 if @count == 0 self.opacity = opacity.zero? ? 255 : 0 if @count == 20 end end #-------------------------------------------------------------------------- # ● ビットマップの作成 #-------------------------------------------------------------------------- def create_bitmap self.bitmap = Bitmap.new(96, 48) self.bitmap.font.size = 32 self.bitmap.font.color.set(255, 255, 255) end #-------------------------------------------------------------------------- # ● 描画用テキストの作成 #-------------------------------------------------------------------------- def timer_text count = $game_timer.count sprintf("%02d:%02d:%02d", @total_sec / 60, @total_sec % 60, count) end end