Motion
Get Motion

ReferenceScripting APIMotionSceneon

MotionScene.on

method

Listens for something happening.

Nameon
Kindmethod of MotionScene
Called asscene.on(…)
Since0.3

Syntax

on<E extends keyof MotionEvents>(    event: E,    fn: MotionEvents[E],    options?: MotionEventOptions): () => void

Parameters

NameTypeDescription
eventEWhat to listen for: click, press, pointer, beat, tick, props... (the Events)
fnMotionEvents[E]What runs, with what the event hands it
optionsMotionEventOptionsOptional. For loud and quiet: how loud (level) and how long (seconds)

Returns

() => void: a function that stops listening.

Remarks

Throws for an event there's no such thing as.

Example

scene.on("click", (x, y) => scene.particles("Sparks").burst(50, { x, y }));

See also

MotionEvents · MotionEventOptions · In examples: Constellations, Kelp Forest, Pulse, Rain Harbour, Resonance, Valley Hours, Vent Garden