The State Manager used for managing the different states of a game or site
springroll.StateManager
[transitionSounds]
[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.
_onStateLoaded
When the state has completed its loading sequence. This should be treated as an asynchronous process.
_onTransitionIn
When the transition into a state has finished playing during a state change.
_onTransitionLoading
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
When the transition out of a state has finished playing during a state change.
addState
id
state
Register a state with the state manager, done initially
id
String
The string alias for a state
state
springroll.State
State object reference
changeTransition
transition
See see transition
transition
The transition clip
getCurrentState
Get the current state, see see currentState
The current state
getStateById
id
Access a certain state by the ID
id
String
State alias
The base State object
has
name
[callback]
Checks if the EventDispatcher has a specific listener or any listener for a given event.
If the EventDispatcher has the specified listener.
isBusy
If the StateManager is busy because it is currently loading or transitioning.
If StateManager is busy
loadingStart
If the state needs to do some asyncronous tasks, The state can tell the manager to stop the animation
off
name
callback
Remove the event listener
Return this EventDispatcher for chaining calls.
on
name
callback
[priority=0]
Add an event listener. The parameters for the listener functions depend on the event.
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.
Return this EventDispatcher for chaining calls.
once
name
callback
[priority=0]
Add an event listener but only handle it one time.
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.
Return this EventDispatcher for chaining calls.
refresh
This transitions out of the current state and enters it again. Can be useful for clearing a state
showTransitionIn
callback
Displays the transition in animation, without changing states.
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.
callback
Function
The function to call when the animation is complete.
trigger
type
arguments
Dispatch an event
type
String
The type of event to trigger
arguments
Additional parameters for the listener functions.
transition
The click to play in between transitioning states
waitForLoadingComplete
Wait to fire the onTransitionIn event until the onTransitionLoading loop reaches it’s final frame.
onInitDone
The name of the event for initialization complete - the first state is then being entered.
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.
progress
The amount of progress while state is being preloaded from zero to 1
percentage
Number
The amount loaded