Class: Sprite_Timer

Inherits:
Text show all
Defined in:
scripts/01450 Systems/00003 Map Engine/00001 Graphics/03400 Sprite_Timer.rb

Overview

Display the main Timer on the screen

Instance Attribute Summary

Attributes inherited from LiteRGSS::Text

#__index__, #align, #bold, #draw_shadow, #fill_color, #height, #italic, #nchar_draw, #opacity, #outline_color, #outline_thickness, #real_width, #size, #text, #viewport, #visible, #width, #x, #y, #z

Instance Method Summary collapse

Methods inherited from Text

#simple_mouse_in?, #translate_mouse_coords

Methods inherited from LiteRGSS::Text

#load_color, #multiline_text=, new, #set_position, #text_width

Methods inherited from LiteRGSS::Disposable

#dispose, #disposed?

Constructor Details

#initialize(viewport = nil) ⇒ Sprite_Timer

Create the timer with its surface



6
7
8
9
10
11
12
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/03400 Sprite_Timer.rb', line 6

def initialize(viewport = nil)
  w = 48
  super(0, viewport, Graphics.width - w, 0 - Text::Util::FOY, 48, 32, nil.to_s, 1)
  load_color(9)
  self.z = 500
  update
end

Instance Method Details

#update

Update the timer according to the frame_rate and the number of frame elapsed.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/03400 Sprite_Timer.rb', line 14

def update
  # タイマー作動中なら可視に設定
  self.visible = $game_system.timer_working
  # タイマーを再描画する必要がある場合
  if $game_system.timer / 60 != @total_sec # Graphics.frame_rate
    # トータル秒数を計算
    @total_sec = $game_system.timer / 60#Graphics.frame_rate
    # タイマー表示用の文字列を作成
    min = @total_sec / 60
    sec = @total_sec % 60
    # タイマーを描画
    self.text = sprintf("%02d:%02d", min, sec)
  end
end