Skip to content

Sensing functions

Free functions you can call directly in sprite code.

andClones(): Sprite[]

Get this sprite together with all of its clones.

Delegates to Sprite.andClones

askAndWait(question: string): void

Ask the user a question and wait for an answer.

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

Delegates to Sprite.askAndWait

colorTouching(color: Color, target: any): boolean

Check whether this sprite is touching a given color.

Delegates to Sprite.colorTouching

getAnswer(): string | null

Get the most recent answer from askAndWait.

Delegates to Sprite.answer

getLoudness(): number

Get the current microphone loudness.

Delegates to Sprite.loudness

getMouseX(): number

Get the mouse x position.

Delegates to Sprite.mouse

getMouseY(): number

Get the mouse y position.

Delegates to Sprite.mouse

getSprites(): Sprite[]

Get all sprites in the project.

Delegates to Sprite.sprites

getStage(): Stage

Get the stage object.

Delegates to Sprite.stage

getTimer(): number

Get the value of the project timer in seconds.

Delegates to Sprite.timer

isMouseDown(): boolean

Check whether the mouse button is down.

Delegates to Sprite.mouse

keyPressed(key: string): boolean

Check whether a key is currently pressed.

Delegates to Sprite.keyPressed

nearestEdge(): string

Get the nearest edge this sprite is touching.

Delegates to Sprite.nearestEdge

restartTimer(): void

Reset the project timer to zero.

Delegates to Sprite.restartTimer

touching(target: "mouse" | "edge" | Sprite): boolean

Check whether this sprite is touching a target, “mouse”, or “edge”.

Delegates to Sprite.touching