Listeners

⚠️ Listeners are still in early development and not currently supported. You have to set up your own listeners for your platform.

Defining Listeners inside the state machine structure allows for the automatic set up of them on the player side.

Quick start:

addStateMachine({
descriptor: {
...
},
states: [
...
],
transitions: [
...
],
listeners: [
{
type: "PointerDown",
},
...
]
})

Usage

Any listener will be automatically set up inside the player on each respective platform. If there is an action defined on the listener, it will be executed when the assigned gesture is captured.

This does not stop you from defining your own listeners and posting events to the state machine.

Format

"listeners": [
{
"type": "PointerUp" | "PointerDown" | "PointerEnter" | "PointerExit" | "PointerMove",
"target": string?,
"action": INCREMENT, DECREMENT, SET, NONE,
"value": string | boolean | int,
"context_key": string,
}
],

type?: string

Define the type of listener.

Can be either PointerUp, PointerDown, PointerEnter, PointerExit, PointerMove.


target?: string

The layer id.


action?: string

Define which action to perform on a context variable.

Can be either INCREMENT, DECREMENT, SET, NONE.


value?: string | boolean | int

The value to set to the context variable defined by the context_key and taking in to account the defined action.


context_key: string

The id of the context variable to modify.