Class: StateManager

PhaserComps.ComponentClip. StateManager

For ComponentClip internal use only

Shows or hides component view instances depending on which state is active. Helps to get current active components by keys.


new StateManager(clip, config)

Parameters:
Name Type Description
clip PhaserComps.ComponentClip

state manager creator clip instance

config Object

Main component states config object

Methods


addComponent(component, childId [, childKey])

Parameters:
Name Type Argument Description
component PhaserComps.ComponentClip | Phaser.GameObjects.GameObject

component view instance, it may be text, image, sprite, or ComponentView instance

childId String

unique child id from component config

childKey String <optional>

child key from component config


getActiveComponentByKey(key)

Get component with provided key, if exists and is present in current state

Parameters:
Name Type Description
key String

Component key to get

Returns:
Type
ComponentClip | Phaser.GameObjects.Image | Phaser.GameObjects.TileSprite | Phaser.GameObjects.Text | null

getStateConfigById(stateId)

Get raw state config object by state id

Parameters:
Name Type Description
stateId String

state id


setState(stateId, force)

Setup state with provided stateId, if exists

Parameters:
Name Type Description
stateId String

state id to setup

force Boolean

if true, update state even if stateId was not changed