StateManager Class
The State Manager used for manaing the different states of a game or site
Constructor
StateManager
-
transition
-
audio
Parameters:
-
transition
createjs.MovieClip | PIXI.MovieClip | PIXI.SpineThe transition MovieClip to play between transitions
-
audio
ObjectData object with aliases and start times (seconds) for transition in, loop and out sounds: {in:{alias:"myAlias", start:0.2}}. These objects are in the format for Animator or PixiAnimator from CloudKidAnimation, so they can be the alias instead of an object.
Item Index
Methods
- _loopTransition
- _onStateLoaded
- _processQueue
- _transitioning
- addEventListener
- addState
- changeTransition
- destroy
- dispatchEvent
- getCurrentState
- getState
- getStateById
- hasEventListener
- hideBlocker
- intialize
- isBusy
- loadingDone
- loadingStart
- refresh
- removeAllEventListeners
- removeEventListener
- setState
- showBlocker
- showTransitionIn
- showTransitionOut
- update
Properties
Methods
_loopTransition
()
private
Plays the animation "transitionLoop" on the transition. Also serves as the animation callback. Manually looping the animation allows the animation to be synced to the audio while looping.
_onStateLoaded
()
private
When the state has completed it's loading sequence this should be treated as an asyncronous process
_processQueue
()
private
Process the state queue
Returns:
If there is a queue to process
_transitioning
-
The
-
The
Generalized function for transitioning with the manager
addState
-
id
-
state
Register a state with the state manager, done initially
changeTransition
-
Clip
Dynamically change the transition
Parameters:
-
Clip
createjs.MovieClip | PIXI.MovieClip | PIXI.Spineto swap for transition
destroy
()
Remove the state manager
dispatchEvent
-
enventObj
-
target
Dispatches the specified event
Parameters:
Returns:
Returns true if any listener returned true
getCurrentState
()
BaseState
Get the current selected state (state object)
Returns:
The Base State object
getStateById
-
id
Access a certain state by the ID
Parameters:
-
id
StringState alias
Returns:
The base State object
hasEventListener
-
type
Indicates whether there is at least one listener for the specified event type
Parameters:
-
type
StringThe string type of the event
Returns:
Returns true if there is at least one listener for the specified event
hideBlocker
()
Re-enable interaction with the stage
intialize
-
transition
-
transitionSounds
Initialize the State Manager
Parameters:
-
transition
createjs.MovieClip | PIXI.MovieClip | PIXI.SpineThe transition MovieClip to play between transitions
-
transitionSounds
ObjectData object with aliases and start times (seconds) for transition in, loop and out sounds: {in:{alias:"myAlias", start:0.2}}
isBusy
()
Bool
If the StateManager is busy because it is currently loading or transitioning.
Returns:
If StateManager is busy
loadingDone
()
If the state has finished it's asyncronous task loading Lets enter the state
loadingStart
()
If the state needs to do some asyncronous tasks, The state can tell the manager to stop the animation
refresh
()
This transitions out of the current state and enters it again. Can be useful for clearing a state
removeAllEventListeners
-
type
Removes all listeners for the specified type, or all listeners of all types
Parameters:
-
type
StringThe string type of the event. If omitted, all listeners for all types will be removed.
removeEventListener
-
type
-
listener
Removes the specified event listener
showBlocker
()
Show, enable the blocker clip to disable mouse clicks
showTransitionIn
-
callback
Displays the transition in animation, without changing states.
Parameters:
-
callback
FunctionThe function to call when the animation is complete.
showTransitionOut
-
callback
Displays the transition out animation, without changing states.
Parameters:
-
callback
FunctionThe function to call when the animation is complete.
update
-
elasped
The frame update function
Parameters:
-
elasped
IntThe ms since the last frame
Properties
_destroyed
Bool
private
If the current object is destroyed
_isTransitioning
Bool
private
If the state or manager is current transitioning
_transition
createjs.MovieClip
private
The click to play in between transitioning states
name description
Bool
private
If the manager is loading a state
Events
onBlockerHide
The name of the Animator label and event for hiding the blocker
onBlockerHideDone
The name of the Animator label and event for hiding the blocker
onBlockerShow
The name of the Animator label for showing the blocker
onBlockerShowDone
The name of the Animator label for showing the blocker
onInit
The name of the Animator label and event for initializing
onInitDone
The name of the event for done with initializing
onLoadingDone
Event when the state transitions the first time
onLoadingStart
Event when the state transitions the first time
onTransitionIn
The name of the Animator label and event for transitioning state in
onTransitionInDone
The name of the event for done with transitioning state in
onTransitionOut
The name of the Animator label and event for transitioning state out
onTransitionOutDone
The name of the event for done with transitioning state out