Class: UIComponentPrototype

PhaserComps.UIComponents. UIComponentPrototype

Base ComponentView controller class. Used to setup component state and texts. Once root instance is created, you must append a ComponentClip instance to it.

Child clips will be appended automatically on every state change, their clips will be found by keys. On state change notifies all child components to update their states.

One of the main ideas of this framework is if there is no clip for UIComponentPrototype at current state or at all, nothing bad happens.


new UIComponentPrototype( [parent] [, key])

Parameters:
Name Type Argument Description
parent PhaserComps.UIComponents.UIComponentPrototype <optional>

UIComponentPrototype instance to find clip inside

key String <optional>

key to find clip inside parent

Properties:
Name Type Description
lockId String

Used by UIManager, see PhaserComps.UIManager

Extends

  • Phaser.Events.EventEmitter

Methods


appendClip(clip)

Append a instance to this to control it. State setup will be processed immediately.
Use only for root instance, child instances will be appended automatically depending on state of this.

Parameters:
Name Type Description
clip PhaserComps.ComponentClip

ComponentView instance to append


<protected> destroy( [fromScene])

Destroy ComponentPrototype and clip, if exists

Parameters:
Name Type Argument Default Description
fromScene Boolean <optional>
false

<protected> doState()

Call doState to setup new state, id is provided by getStateId

See:

<protected> getStateId()

Current state id, used by doState method

Returns:
Type
String

getText(key)

Returns saved text by key, if it was set previously

Parameters:
Name Type Description
key String
Returns:

text value

Type
String | Array.<String>

<protected> onClipAppend(clip)

Override this, if you want to do something, when new clip removed,

Parameters:
Name Type Description
clip PhaserComps.ComponentClip

<protected> onClipProcess()

Override this, if you want to do something, when state or clip changes.


<protected> onClipRemove(clip)

Override this, if you want to do something, when new clip removed, like remove clip events listeners.

Parameters:
Name Type Description
clip

<protected> removeClip()


setText(key, text)

Set text value to the textfield with provided key. Text value is saved in the component's instance dictionary and will be set to the textField on every state change

Parameters:
Name Type Description
key String

TextField key

text String | Array.<String>

text string