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.

See also Sprite.broadcast

broadcastAndWait(message: string): void

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

⏸️ This pauses your script until it finishes — the next line runs only after it’s done.

See also Sprite.broadcastAndWait

whenBackdropChanged(method: Function): void

Run a method when the stage backdrop changes.

See also Sprite.whenBackdropChanged

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

Run a method when a matching broadcast is received.

See also Sprite.whenBroadcast

whenClicked(method: Function): void

Run a method when this sprite is clicked.

See also Sprite.whenClicked

Used by

whenClickedOrTapped(method: Function): void

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

See also Sprite.whenClickedOrTapped

whenCloneStart(method: Function): void

Run a method when a clone of this sprite starts.

See also Sprite.whenCloneStart

Used by

whenGreenFlag(method: Function): void

Run a method when the green flag is clicked.

See also 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.

See also Sprite.whenKeyPressed

Used by

whenTouchEnd(method: Function): void

Run a method when a touch on this sprite ends.

See also Sprite.whenTouchEnd

whenTouchMove(method: Function): void

Run a method when a touch on this sprite moves.

See also Sprite.whenTouchMove

whenTouchStart(method: Function): void

Run a method when a touch on this sprite begins.

See also Sprite.whenTouchStart