Class: PopupText

Inherits:
Chingu::GameObject
  • Object
show all
Defined in:
lib/prkwars/popuptext.rb

Overview

Class used for messages that pop up on the screen whenever something relevant happens - e.g. score goes up.

Instance Method Summary collapse

Constructor Details

#initialize(message, x, y, options = {}) ⇒ PopupText

Returns a new instance of PopupText.



10
11
12
13
14
15
16
# File 'lib/prkwars/popuptext.rb', line 10

def initialize(message, x, y, options = {})
  super(options)

  @velocity_x = 0
  @velocity_y = -2
  @msg = Chingu::Text.create(message, x: x, y: y, size: 30)
end

Instance Method Details

#updateObject



18
19
20
21
22
# File 'lib/prkwars/popuptext.rb', line 18

def update
  @msg.y -= 1
  @msg.color.alpha -= 4
  @msg.destroy! if color.alpha.zero?
end