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.

See also Sprite.andClones

askAndWait(question: string): void

Ask the user a question and wait for an answer.

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

See also Sprite.askAndWait

Used by

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

Check whether this sprite is touching a given color.

See also Sprite.colorTouching

getAnswer(): string | null

Get the most recent answer from askAndWait.

See also Sprite.answer

Used by

getLoudness(): number

Get the current microphone loudness.

See also Sprite.loudness

getMouseX(): number

Get the mouse x position.

See also Sprite.mouse

Used by

getMouseY(): number

Get the mouse y position.

See also Sprite.mouse

Used by

getSprites(): Sprite[]

Get all sprites in the project.

See also Sprite.sprites

getStage(): Stage

Get the stage object.

See also Sprite.stage

getTimer(): number

Get the value of the project timer in seconds.

See also Sprite.timer

isMouseDown(): boolean

Check whether the mouse button is down.

See also Sprite.mouse

keyPressed(key: string): boolean

Check whether a key is currently pressed.

See also Sprite.keyPressed

nearestEdge(): string

Get the nearest edge this sprite is touching.

See also Sprite.nearestEdge

restartTimer(): void

Reset the project timer to zero.

See also Sprite.restartTimer

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

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

See also Sprite.touching

Used by