Skip to content

Events functions

Free functions you can call directly in sprite code.

broadcast(message: string): void

Send a broadcast message to all sprites without waiting.

Delegates to Sprite.broadcast

broadcastAndWait(message: string): void

Send a broadcast message and wait until all receiving scripts finish.

Pauses the script (a generator). In sprite code the free-function wrapper awaits it for you.

Delegates to Sprite.broadcastAndWait

whenBackdropChanged(method: Function): void

Run a method when the stage backdrop changes.

Delegates to Sprite.whenBackdropChanged

whenBroadcast(nameOrOptions: string | object, method: Function): void

Run a method when a matching broadcast is received.

Delegates to Sprite.whenBroadcast

whenClicked(method: Function): void

Run a method when this sprite is clicked.

Delegates to Sprite.whenClicked

Used by

whenClickedOrTapped(method: Function): void

Run a method when this sprite is clicked or tapped (mobile).

Delegates to Sprite.whenClickedOrTapped

whenCloneStart(method: Function): void

Run a method when a clone of this sprite starts.

Delegates to Sprite.whenCloneStart

whenGreenFlag(method: Function): void

Run a method when the green flag is clicked.

Delegates to Sprite.whenGreenFlag

Used by

whenKeyPressed(keyOrOptions: "space" | "up arrow" | "down arrow" | "right arrow" | "left arrow" | "any" | object, method: Function): void

Run a method when a key is pressed.

Delegates to Sprite.whenKeyPressed

Used by

whenTouchEnd(method: Function): void

Run a method when a touch on this sprite ends.

Delegates to Sprite.whenTouchEnd

whenTouchMove(method: Function): void

Run a method when a touch on this sprite moves.

Delegates to Sprite.whenTouchMove

whenTouchStart(method: Function): void

Run a method when a touch on this sprite begins.

Delegates to Sprite.whenTouchStart