Loading project...
Properties and methods for working with sprites.
sprite.move(amount):
Moves the sprite by the specified amount.Example: sprite.move(10)
sprite.x:
The horizontal position of the sprite.Example: sprite.x = 100
sprite.y:
The vertical position of the sprite.Example: sprite.y = 200
sprite.rotation:
The rotation of the sprite in degrees.Example: sprite.rotation = 45
sprite.pointTowards(x, y):
Points sprite towards a specific position.Example: sprite.pointTowards(100, 200)
Properties for sprite appearance.
sprite.visible:
Whether the sprite is visible.Example: sprite.visible = false
sprite.size:
The size of the sprite.Example: sprite.size = 50
sprite.layer:
The layer of the sprite.Example: sprite.layer = 1
sprite.transparency:
The transparency of the sprite (0-100).Example: sprite.transparency = 50
sprite.brightness:
The brightness of the sprite (0-100).Example: sprite.brightness = 50
Functions for controlling timing and execution flow.
forever(function):
Runs the function every frame.Example: forever(function() { sprite.x += 1 })
for(let i = 0; i < n; i++) { ... }:
Runs the code in the curly braces n times.Example: for(let i = 0; i < 10; i++) { sprite.x += 1 }
while (condition) { ... }
Runs the code in the curly braces repeatedly while the condition is true.Example: while (sprite.x < 100) { sprite.x += 1 }
if (condition) { ... }
Executes the block if the condition is true.Example: if (sprite.x > 100) { sprite.visible = false }
if (condition) { ... } else { ... }
Executes one block if the condition is true, otherwise runs the else block.Example: if (sprite.x > 100) { sprite.visible = false } else { sprite.visible = true }
sendMessage("messageName")
Sends a message to all sprites.Example: sendMessage("gameOver")
sendMessage("messageName", {data: any})
Sends a message to all sprites with specified data.Example: sendMessage("gameOver", { score: 100, level: 1 })
onMessage("messageName", function(data) { ... })
Receives a message and runs the code in the curly braces when the message is received.Example: onMessage("gameOver", function(data) { Game.stop() })
wait(seconds):
Waits for specified seconds.Example: function move() { wait(1); sprite.x += 10; }
Functions for handling detection and keyboard and mouse input.
sprite.isTouching("spriteName"):
Checks if the sprite is touching the other sprite with the given name.Example: if (sprite.isTouching("Enemy")) { ... }
sprite.touchingMouse():
Checks if the sprite is touching the mouse cursor.Example: if (sprite.touchingMouse()) { ... }
Keyboard.keyDown(key):
Returns true if key was just pressed.Example: if (Keyboard.keyDown(Key.Space)) { sprite.y += 10 }
Keyboard.keyHeld(key):
Returns true if key is being held down.Example: if (Keyboard.keyHeld(Key.ArrowRight)) { sprite.x += 1 }
Keyboard.keyUp(key):
Returns true if key was just released.Example: if (Keyboard.keyUp(Key.Space)) { sprite.y -= 10 }
Mouse.isDown(button):
Returns true if mouse button is pressed.Example: if (Mouse.isDown(MouseButton.Left)) { sprite.size += 10 }
Mouse.isHeld(button):
Returns true if mouse button is held down.Example: if (Mouse.isHeld(MouseButton.Left)) { sprite.size += 1 }
Mouse.isUp(button):
Returns true if mouse button is released.Example: if (Mouse.isUp(MouseButton.Left)) { sprite.size -= 1 }
Mouse.x:
The current horizontal position of the mouse cursor.Example: sprite.x = Mouse.x
Mouse.y:
The current vertical position of the mouse cursor.Example: sprite.y = Mouse.y
Mathematical functions, comparisons, and constants.
Math.random(min, max):
Returns a random number between min and max.Example: let n = Math.random(0, 10)
Math.round(value):
Rounds the value to the nearest whole number.Example: Math.round(0.5)
Math.floor(value):
Rounds the value down to the nearest whole number.Example: Math.floor(0.5)
Math.ceil(value):
Rounds the value up to the nearest whole number.Example: Math.ceil(0.5)
Math.abs(value):
Returns the absolute (positive) value.Example: let distance = Math.abs(x - y)
<
Returns true if the left value is less than the right value.Example: if (x < 10) { ... }
>
Returns true if the left value is greater than the right value.Example: if (score > 100) { ... }
<=
Returns true if the left value is less than or equal to the right value.Example: if (lives <= 0) { Game.stop() }
>=
Returns true if the left value is greater than or equal to the right value.Example: if (score >= 100) { ... }
==
Checks if two values are equal.Example: if (level == 2) { ... }
!=
Checks if two values are not equal.Example: if (sprite.x != 0) { ... }
Math.sin(angle):
Returns the sine of the angle (in degrees).Example: let y = Math.sin(90)
Math.cos(angle):
Returns the cosine of the angle (in degrees).Example: let x = Math.cos(0)
Math.tan(angle):
Returns the tangent of the angle (in degrees).Example: let slope = Math.tan(45)
Math.PI:
Represents the mathematical constant π (~3.14159).Example: let radius = 2 * Math.PI * r
Math.E:
Represents Euler’s number (~2.718).Example: let growth = Math.E ** time
Functions for working with sprite clones.
onCloneStart(function(clone){ ... }):
Runs when a clone is created.Example: onCloneStart((clone) => { clone.x = 0 })
createClone():
Creates a clone of the current sprite, or the sprite with the given name if provided.Example: let newSprite = createClone()
clone.delete()
Deletes the current clone in the onCloneStart.Example: clone.delete()
Core game functions and properties.
Game.stop():
Stops the game.Example: Game.stop()
Game.width:
The width of the game window.Example: sprite.x = Game.width / 2
Game.height:
The height of the game window.Example: sprite.y = Game.height / 2
Declare and work with variables in your code.
let variableName: type = value:
Declares a variable with a specific type.Example: let score: number = 0
variableName = newValue:
Updates the value of an existing variable.Example: score = score + 1
globals.variableName = value:
Declares a global variable that can be changed.Example: globals.playerName = "Wispy"
Create, modify, and access array data.
let array: type[] = []:
Creates a new empty array. Types include: number, string, boolean, etc.Example: let scores: number[] = []
array.push(value):
Adds a value to the end of the array.Example: scores.push(10)
array.splice(index, 1):
Removes the item at the given index.Example: scores.splice(2, 1)
array.splice(index, 0, item):
Inserts an item at the specified index.Example: scores.splice(1, 0, 99)
array[index] = item:
Replaces the item at the specified index.Example: scores[0] = 42
array[index]:
Gets the item at the given index.Example: let value = scores[1]
array.length:
Gets the number of items in the array.Example: let count = scores.length
array[0]:
Gets the first item in the array.Example: let first = scores[0]
array[array.length - 1]:
Gets the last item in the array.Example: let last = scores[scores.length - 1]
array.sort():
Sorts the array alphabetically or numerically.Example: scores.sort()
array.reverse():
Reverses the order of the array.Example: scores.reverse()
array.map(item => ...):
Creates a new array by transforming each item.Example: let doubled = scores.map(x => x * 2)
array.filter(item => ...):
Creates a new array with only the items that pass the condition.Example: let highScores = scores.filter(x => x > 50)
globals.arrayName = value:
Declares a global array that can be changed.Example: globals.playerNames = ["Wispy", "Puff"]