API Documentation for: 1.1.2
Show:

StateManager Class

Defined in: StateManager:24
Namespace: cloudkid

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

Constructor

StateManager

(
  • transition
  • audio
)

Defined in StateManager:24

Parameters:

  • transition createjs.MovieClip | PIXI.MovieClip | PIXI.Spine

    The transition MovieClip to play between transitions

  • audio Object

    Data 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.

Methods

_loopTransition

() private

Defined in _loopTransition:625

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

Defined in _onStateLoaded:562

When the state has completed it's loading sequence this should be treated as an asyncronous process

_processQueue

() private

Defined in _processQueue:603

Process the state queue

Returns:

If there is a queue to process

_transitioning

(
  • The
  • The
)
private

Defined in _transitioning:695

Generalized function for transitioning with the manager

Parameters:

  • The String

    animator event to play

  • The Function

    callback function after transition is done

addEventListener

(
  • type
  • listener
)
Function | Object

Defined in addEventListener:41

Adds the specified event listener

Parameters:

  • type String

    The string type of the event

  • listener Function | Object

    An object with a handleEvent method, or a function that will be called when the event is dispatched

Returns:

Function | Object:

Returns the listener for chaining or assignment

addState

(
  • id
  • state
)

Defined in addState:294

Register a state with the state manager, done initially

Parameters:

  • id String

    The string alias for a state

  • state BaseState

    State object reference

changeTransition

(
  • Clip
)

Dynamically change the transition

Parameters:

  • Clip createjs.MovieClip | PIXI.MovieClip | PIXI.Spine

    to swap for transition

destroy

()

Defined in destroy:746

Remove the state manager

dispatchEvent

(
  • enventObj
  • target
)
Bool

Defined in dispatchEvent:65

Dispatches the specified event

Parameters:

  • enventObj Object | String

    An object with a "type" property, or a string type

  • target Object

    The object to use as the target property of the event object

Returns:

Bool:

Returns true if any listener returned true

getCurrentState

() BaseState

Defined in getCurrentState:347

Get the current selected state (state object)

Returns:

BaseState:

The Base State object

getState

() String

Defined in getState:336

Get the currently selected state

Returns:

String:

The id of the current state

getStateById

(
  • id
)
BaseState

Defined in getStateById:358

Access a certain state by the ID

Parameters:

Returns:

BaseState:

The base State object

hasEventListener

(
  • type
)
Bool

Defined in hasEventListener:74

Indicates whether there is at least one listener for the specified event type

Parameters:

  • type String

    The string type of the event

Returns:

Bool:

Returns true if there is at least one listener for the specified event

hideBlocker

()

Defined in hideBlocker:440

Re-enable interaction with the stage

intialize

(
  • transition
  • transitionSounds
)

Defined in intialize:265

Initialize the State Manager

Parameters:

  • transition createjs.MovieClip | PIXI.MovieClip | PIXI.Spine

    The transition MovieClip to play between transitions

  • transitionSounds Object

    Data object with aliases and start times (seconds) for transition in, loop and out sounds: {in:{alias:"myAlias", start:0.2}}

isBusy

() Bool

Defined in isBusy:371

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

Returns:

Bool:

If StateManager is busy

loadingDone

()

Defined in loadingDone:401

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

loadingStart

()

Defined in loadingStart:382

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

refresh

()

Defined in refresh:462

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 String

    The string type of the event. If omitted, all listeners for all types will be removed.

removeEventListener

(
  • type
  • listener
)

Removes the specified event listener

Parameters:

  • type String

    The string type of the event

  • listener Function | Object

    The listener function or object

setState

(
  • id
)

Defined in setState:474

Set the current State

Parameters:

showBlocker

()

Defined in showBlocker:415

Show, enable the blocker clip to disable mouse clicks

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.

Parameters:

  • callback Function

    The function to call when the animation is complete.

update

(
  • elasped
)

Defined in update:732

The frame update function

Parameters:

  • elasped Int

    The ms since the last frame

Properties

_destroyed

Bool private

Defined in _destroyed:165

If the current object is destroyed

_isTransitioning

Bool private

If the state or manager is current transitioning

_listeners description

Array private

Createjs EventDispatcher method

_oldState

BaseState private

Defined in _oldState:141

The old state

_queueStateId

String private

Defined in _queueStateId:173

If we're transitioning the state, the queue the id of the next one

_state

BaseState private

Defined in _state:125

The currently selected state

_stateID

String private

Defined in _stateID:133

The currently selected state id

_states

Array private

Defined in _states:117

The collection of states map

_transition

createjs.MovieClip private

Defined in _transition:101

The click to play in between transitioning states

_transitionSounds

Object private

The sounds for the transition

name description

Bool private

If the manager is loading a state

VERSION

String final static

Defined in VERSION:92

The current version of the state manager

Events

onBlockerHide

Defined in onBlockerHide:223

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

Defined in onBlockerShow:209

The name of the Animator label for showing the blocker

onBlockerShowDone

The name of the Animator label for showing the blocker

onInit

Defined in onInit:237

The name of the Animator label and event for initializing

onInitDone

Defined in onInitDone:244

The name of the event for done with initializing

onLoadingDone

Defined in onLoadingDone:258

Event when the state transitions the first time

onLoadingStart

Defined in onLoadingStart:251

Event when the state transitions the first time

onTransitionIn

Defined in onTransitionIn:181

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

Defined in onTransitionOut:195

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

onTransitionOutDone

The name of the event for done with transitioning state out