Sensing

Ask questions about the world: input, collisions, mouse/keyboard state, time, and dates.

isTouching
// Check whether the sprite is touching another sprite
self.isTouching(self);
isTouchingBackdropColor
// Check whether the sprite is touching a color on the backdrop
self.isTouchingBackdropColor(Color.fromHex("#ff0000"));
isTouchingEdge
// Check whether the sprite is touching the edge of the stage
self.isTouchingEdge();
isTouchingMouse
// Check whether the sprite is touching the mouse pointer
self.isTouchingMouse();
distanceTo
// Get the distance from the sprite to a point
self.distanceTo(0, 0);
ask
// Ask the user a question and wait for an answer
self.ask("What's your name?");
isKeyPressed
// Check whether a key is currently pressed
self.isKeyPressed("any");
mouseDown
// Check whether the mouse button is pressed
self.mouseDown;
mouseX
// Get the mouse pointer's x position
self.mouseX;
mouseY
// Get the mouse pointer's y position
self.mouseY;
width
// Get the width of the stage
self.width;
height
// Get the height of the stage
self.height;
property
// Get a property of another sprite or the stage
$["Stage"].width;
isTurbo
// Check whether turbo mode is enabled
Scrap.isTurbo();
draggable
// Check whether the sprite can be dragged
self.draggable;
setDraggable
// Set whether the sprite can be dragged
self.draggable = true;
resetTimer
// Reset the timer back to zero
self.resetTimer();
getTimer
// Get the number of seconds since the timer was reset
self.getTimer();
date
// Create a date from a specific calendar date
new Date("2026-06-30");
View on MDN ↗
today
// Get the current date and time
new Date();
View on MDN ↗
dateProperty_date
// Get a part (such as the year) of a specific date
new Date("2026-06-30").getFullYear();
View on MDN ↗
dateProperty_today
// Get a part (such as the year) of the current date
new Date().getFullYear();
View on MDN ↗
alert
// Show a browser alert dialog with a message
window.alert("Hello!");
View on MDN ↗
prompt
// Show a browser prompt asking the user for text
window.prompt("What's your name?");
View on MDN ↗
confirm
// Show a confirmation dialog and get a yes/no answer
window.confirm("Are you sure?");
View on MDN ↗