Util gamestate

Gamestate management functions.

Based on hump.gamestate.

Functions

new ([parent]) Create new gamestate.
switch (to, ...) Switch to a gamestate.
push (to, ...) Push a new gamestate on the stack.
pop (...) Pops the current state, switching back to the one below.
current () Get current gamestate.
drawStack () Draw all gamestates on the stack.


Functions

new ([parent])
Create new gamestate.

Parameters:

  • parent table gamestate (optional)

Returns:

    table gamestate table
switch (to, ...)
Switch to a gamestate. Switching a gamestate will call the leave() callback on the current gamestate, replace the current gamestate with to, call the init() function if the state was not yet inialized and finally call enter(old_state, ...) on the new gamestate.

Parameters:

  • to table target gamestate
  • ... mixed parameters to pass to to:enter(current,...)

Returns:

    results of to:enter(current, ...)
push (to, ...)
Push a new gamestate on the stack. Pushes the to on top of the state stack, i.e. makes it the active state. Semantics are the same as switch(to, ...), except that leave() is not called on the previously active state. Useful for pause screens, menus, etc.

Parameters:

  • to table target gamestate
  • ... mixed parameters to pass to to:enter(current,...)

Returns:

    results of to:enter(current, ...)
pop (...)
Pops the current state, switching back to the one below. Calls leave() on the current state and then removes it from the stack, making the state below the current state and calls resume(...) on the activated state. Does not call enter() on the activated state.

Parameters:

  • ... mixed parameters to pass to the new state

Returns:

    mixed results of new_state:resume(...)
current ()
Get current gamestate.

Returns:

    table current gamestate
drawStack ()
Draw all gamestates on the stack. Calls the .draw() function of all gamestates on the stack, from bottom to top.
generated by LDoc 1.4.3 Last updated 2015-04-20 03:01:38