Class: PopupText
- Inherits:
-
Chingu::GameObject
- Object
- Chingu::GameObject
- PopupText
- 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
-
#initialize(message, x, y, options = {}) ⇒ PopupText
constructor
Initialization method for
PopupTextrequires x, y to determine where the message gets spawned on the screen. -
#update ⇒ Object
Updating the popuptext changes the y coordinate and slowly fades the message out.
Constructor Details
#initialize(message, x, y, options = {}) ⇒ PopupText
Initialization method for PopupText requires x, y to determine where the message gets spawned on the screen.
13 14 15 16 17 |
# File 'lib/prkwars/popuptext.rb', line 13 def initialize(, x, y, = {}) super() @msg = Chingu::Text.create(, x: x, y: y, size: 30) end |
Instance Method Details
#update ⇒ Object
Updating the popuptext changes the y coordinate and slowly fades the message out.
22 23 24 25 26 |
# File 'lib/prkwars/popuptext.rb', line 22 def update @msg.y -= 1 @msg.color.alpha -= 4 @msg.destroy! if color.alpha.zero? end |