Class: RubyArmor::FloatingText

Inherits:
GameObject
  • Object
show all
Defined in:
lib/ruby_armor/floating_text.rb

Constant Summary collapse

FONT_SIZE =
20

Instance Method Summary collapse

Constructor Details

#initialize(text, options = {}) ⇒ FloatingText

Returns a new instance of FloatingText.



5
6
7
8
9
10
11
# File 'lib/ruby_armor/floating_text.rb', line 5

def initialize(text, options = {})
  super(options)

  @final_y = y - 60
  @text = text
  @font = Font["ProggyCleanSZ.ttf", FONT_SIZE]
end

Instance Method Details

#drawObject



18
19
20
# File 'lib/ruby_armor/floating_text.rb', line 18

def draw
  @font.draw_rel @text, x, y, zorder, 0.5, 0.5, 1, 1, color
end

#updateObject



13
14
15
16
# File 'lib/ruby_armor/floating_text.rb', line 13

def update
  self.y -= 1 # TODO: scale this with FPS.
  destroy if y < @final_y
end