Events functions
Free functions you can call directly in sprite code.
broadcast
Section titled “broadcast”broadcast(message: string): voidSend a broadcast message to all sprites without waiting.
Delegates to Sprite.broadcast
broadcastAndWait
Section titled “broadcastAndWait”broadcastAndWait(message: string): voidSend 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
Section titled “whenBackdropChanged”whenBackdropChanged(method: Function): voidRun a method when the stage backdrop changes.
Delegates to Sprite.whenBackdropChanged
whenBroadcast
Section titled “whenBroadcast”whenBroadcast(nameOrOptions: string | object, method: Function): voidRun a method when a matching broadcast is received.
Delegates to Sprite.whenBroadcast
whenClicked
Section titled “whenClicked”whenClicked(method: Function): voidRun a method when this sprite is clicked.
Delegates to Sprite.whenClicked
Used by
whenClickedOrTapped
Section titled “whenClickedOrTapped”whenClickedOrTapped(method: Function): voidRun a method when this sprite is clicked or tapped (mobile).
Delegates to Sprite.whenClickedOrTapped
whenCloneStart
Section titled “whenCloneStart”whenCloneStart(method: Function): voidRun a method when a clone of this sprite starts.
Delegates to Sprite.whenCloneStart
whenGreenFlag
Section titled “whenGreenFlag”whenGreenFlag(method: Function): voidRun a method when the green flag is clicked.
Delegates to Sprite.whenGreenFlag
Used by
whenKeyPressed
Section titled “whenKeyPressed”whenKeyPressed(keyOrOptions: "space" | "up arrow" | "down arrow" | "right arrow" | "left arrow" | "any" | object, method: Function): voidRun a method when a key is pressed.
Delegates to Sprite.whenKeyPressed
Used by
whenTouchEnd
Section titled “whenTouchEnd”whenTouchEnd(method: Function): voidRun a method when a touch on this sprite ends.
Delegates to Sprite.whenTouchEnd
whenTouchMove
Section titled “whenTouchMove”whenTouchMove(method: Function): voidRun a method when a touch on this sprite moves.
Delegates to Sprite.whenTouchMove
whenTouchStart
Section titled “whenTouchStart”whenTouchStart(method: Function): voidRun a method when a touch on this sprite begins.
Delegates to Sprite.whenTouchStart