springroll.StateManager Class

The State Manager used for managing the different states of a game or site

Constructor

springroll.StateManager

(
  • [transitionSounds]
)

Parameters:

  • [transitionSounds] Object optional

    Data object with aliases and start times (seconds) for transition in, loop and out sounds. Example: {in:{alias:"myAlias", start:0.2}}. These objects are in the format for Animator from EaselJSDisplay or PixiDisplay, so they can be just the sound alias instead of an object.

    • [in] Object | String optional

      The sound to play for transition in

    • [out] Object | String optional

      The sound to play for transition out

    • [loading] Object | String optional

      The sound to play for loading

_onStateLoaded

()
private

Defined in _onStateLoaded:405

When the state has completed its loading sequence. This should be treated as an asynchronous process.

_onTransitionIn

()
private

Defined in _onTransitionIn:438

When the transition into a state has finished playing during a state change.

_onTransitionLoading

()
private

Plays the animation "onTransitionLoading" on the transition. Also serves as the animation callback. Manually looping the animation allows the animation to be synced to the audio while looping.

_onTransitionOut

()
private

When the transition out of a state has finished playing during a state change.

_transitioning

(
  • The
  • The
)
private

Defined in _transitioning:536

Generalized function for transitioning with the manager

Parameters:

  • The String

    animator event to play

  • The Function

    callback function after transition is done

addState

(
  • id
  • state
)

Defined in addState:195

Register a state with the state manager, done initially

Parameters:

changeTransition

(
  • transition
)
deprecated

Defined in changeTransition:18

Deprecated: since version 0.3.0

See see transition

Parameters:

  • transition

    The transition clip

destroy

()

Inherited from springroll.EventDispatcher but overwritten in destroy:572

Remove the state manager

getCurrentState

() springroll.State
deprecated

Defined in getCurrentState:30

Deprecated: since version 0.3.0

Get the current state, see see currentState

Returns:

springroll.State:

The current state

getStateById

(
  • id
)
springroll.State

Defined in getStateById:232

Access a certain state by the ID

Parameters:

Returns:

springroll.State:

The base State object

has

(
  • name
  • [callback]
)
Boolean

Checks if the EventDispatcher has a specific listener or any listener for a given event.

Parameters:

  • name String

    The name of the single event type to check for

  • [callback] Function optional

    The listener function to check for. If omitted, checks for any listener.

Returns:

Boolean:

If the EventDispatcher has the specified listener.

isBusy

() Boolean

Defined in isBusy:245

If the StateManager is busy because it is currently loading or transitioning.

Returns:

Boolean:

If StateManager is busy

loadingDone

()

Defined in loadingDone:271

If the state has finished it's asyncronous task loading Lets enter the state

loadingStart

()

Defined in loadingStart:256

If the state needs to do some asyncronous tasks, The state can tell the manager to stop the animation

next

()
deprecated

Defined in next:54

Deprecated: since version 0.3.0

Goto the next state, see nextState

off

(
  • name
  • callback
)
EventDispatcher

Remove the event listener

Parameters:

  • name String*

    The type of event string separated by spaces, if no name is specifed remove all listeners.

  • callback Function | Array*

    The listener function or collection of callback functions

Returns:

EventDispatcher:

Return this EventDispatcher for chaining calls.

on

(
  • name
  • callback
  • [priority=0]
)
EventDispatcher

Add an event listener. The parameters for the listener functions depend on the event.

Parameters:

  • name String | Object

    The type of event (can be multiple events separated by spaces), or a map of events to handlers

  • callback Function | Array*

    The callback function when event is fired or an array of callbacks.

  • [priority=0] Int optional

    The priority of the event listener. Higher numbers are handled first.

Returns:

EventDispatcher:

Return this EventDispatcher for chaining calls.

once

(
  • name
  • callback
  • [priority=0]
)
EventDispatcher

Add an event listener but only handle it one time.

Parameters:

  • name String | Object

    The type of event (can be multiple events separated by spaces), or a map of events to handlers

  • callback Function | Array*

    The callback function when event is fired or an array of callbacks.

  • [priority=0] Int optional

    The priority of the event listener. Higher numbers are handled first.

Returns:

EventDispatcher:

Return this EventDispatcher for chaining calls.

previous

()
deprecated

Defined in previous:65

Deprecated: since version 0.3.0

Goto the previous state, see previousState

refresh

()

Defined in refresh:302

This transitions out of the current state and enters it again. Can be useful for clearing a state

setState

(
  • id
)
deprecated

Defined in setState:42

Deprecated: since version 0.3.0

Set the current state, see state

Parameters:

showTransitionIn

(
  • callback
)

Displays the transition in animation, without changing states.

Parameters:

  • callback Function

    The function to call when the animation is complete.

showTransitionOut

(
  • callback
)

Displays the transition out animation, without changing states. Upon completion, the transition looping animation automatically starts playing.

Parameters:

  • callback Function

    The function to call when the animation is complete.

trigger

(
  • type
  • arguments
)

Dispatch an event

Parameters:

  • type String

    The type of event to trigger

  • arguments

    Additional parameters for the listener functions.

type

(
  • value
)
String
private

Return type of the value.

Parameters:

  • value

Returns:

String:

The type

_destroyed

Boolean private

Inherited from springroll.EventDispatcher but overwritten in _destroyed:111

If the current object is destroyed

_isTransitioning

Boolean private

If the state or manager is current transitioning

_listeners

Object private

The collection of listeners

_oldState

springroll.State private

Defined in _oldState:87

The old state

_state

springroll.State private

Defined in _state:71

The currently selected state

_stateID

String private

Defined in _stateID:79

The currently selected state id

_states

Object private

Defined in _states:63

The collection of states map

_transitionSounds

Object private

The sounds for the transition

animator

springroll.Animator private

Defined in animator:33

The animator playback.

currentState

springroll.State

Defined in currentState:219

Get the current selected state (state object)

destroyed

Boolean

If the dispatcher is destroyed

enabled

Boolean private

Defined in enabled:284

Internal setter for the enabled status

name description

Boolean private

Defined in name description:95

If the manager is loading a state

state

String

Defined in state:314

Get or change the current state, using the state id.

transition

createjs.MovieClip | springroll.easeljs.BitmapMovieClip | PIXI.Spine

Defined in transition:41

The click to play in between transitioning states

waitForLoadingComplete

Boolean

Wait to fire the onTransitionIn event until the onTransitionLoading loop reaches it’s final frame.

enabled

Defined in enabled:293

If the state manager is enabled, used internally

Event Payload:

onInitDone

Defined in onInitDone:174

The name of the event for initialization complete - the first state is then being entered.

onLoadingDone

Defined in onLoadingDone:188

Event when the state finishes loading assets when it is entered.

onLoadingStart

Defined in onLoadingStart:181

Event when the state begins loading assets when it is entered.

onTransitionIn

Defined in onTransitionIn:137

The name of the Animator label and event for transitioning into a state.

onTransitionInDone

The name of the event for completing transitioning into a state.

onTransitionLoading

The name of the Animator label and event for loading between state change. this event is only dispatched if there is a loading sequence to show in the transition. Recommended to use 'loadingStart' instead for checking.

onTransitionOut

Defined in onTransitionOut:160

The name of the Animator label and event for transitioning out of a state.

onTransitionOutDone

The name of the event for completing transitioning out of a state.

progress

Defined in progress:131

The amount of progress while state is being preloaded from zero to 1

Event Payload:

  • percentage Number

    The amount loaded