class PopupText

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

Public Class Methods

new(message, x, y, options = {}) click to toggle source

Initialization method for PopupText requires x, y to determine where the message gets spawned on the screen.

Calls superclass method
# File lib/prkwars/popuptext.rb, line 13
def initialize(message, x, y, options = {})
  super(options)

  @msg = Chingu::Text.create(message, x: x, y: y, size: 30)
end

Public Instance Methods

update() click to toggle source

Updating the popuptext changes the y coordinate and slowly fades the message out.

# File lib/prkwars/popuptext.rb, line 22
def update
  @msg.y -= 1
  @msg.color.alpha -= 4
  @msg.destroy! if color.alpha.zero?
end