Class AS::Gamestate
In: lib/as_gamestate.rb
Parent: Object

Gamestates are smart gameloops. They not only handle the game loop for you, but also simplify event handling with actions. They also help you manage resources of inactive states.

Methods

action   draw   events   game_loop   input   new   run   stop   stop   update  

Attributes

input_listeners  [R]  During the input phase, input is called on all listeners with the current event. Add your InputPad and StringInput objects must be added to this array.

Public Class methods

Pop the current gamestate and return value.

Public Instance methods

Add an action to run for when the given event occurs.

Called in the gameloop after calling update and clearing the screen if @redraw is true.

Method called during the loop to handle events. Override this method if you wish to handle events in a custom fashion.

Called to run the game loop. Handles events, calls update, and clears and redraws the screen if @redraw is true.

Called from AS::Gamestate#events to process individual events. Calls the input method on all objects in the input_listeners array.

Push the Gamestate onto the state stack. The previous gamestate has its release_state method called if releaseOld is true. When the gamestate exits, the previous gamestate has its load_state method called and the argument to AS::Gamestate#stop is returned.

Pop the gamestate and return value.

Called in the gameloop after events are proccessed.

[Validate]