Motion functions
Free functions you can call directly in sprite code.
changeDirection
Section titled “changeDirection”changeDirection(amount: number): voidChange this sprite’s direction by an amount.
Delegates to Sprite.direction
changeX
Section titled “changeX”changeX(amount: number): voidChange this sprite’s x position by an amount.
Delegates to Sprite.x
Used by
changeY
Section titled “changeY”changeY(amount: number): voidChange this sprite’s y position by an amount.
Delegates to Sprite.y
Used by
getDirection
Section titled “getDirection”getDirection(): numberGet this sprite’s current direction in degrees.
Delegates to Sprite.direction
getX(): numberGet this sprite’s x position.
Delegates to Sprite.x
getY(): numberGet this sprite’s y position.
Delegates to Sprite.y
glide(seconds: number, x: number, y: number): voidGlide this sprite to a position over a number of seconds.
Pauses the script (a generator). In sprite code the free-function wrapper awaits it for you.
Delegates to Sprite.glide
Used by
goto(x: number, y: number): voidMove this sprite to the given x and y coordinates.
Delegates to Sprite.goto
ifOnEdgeBounce
Section titled “ifOnEdgeBounce”ifOnEdgeBounce(): voidBounce off the edge of the stage if touching it.
Delegates to Sprite.ifOnEdgeBounce
Used by
move(steps: number): voidMove this sprite forward by a number of steps.
Delegates to Sprite.move
Used by
pointTowards
Section titled “pointTowards”pointTowards(target: "mouse" | { x: number; y: number }): voidPoint this sprite towards another sprite or the mouse (“mouse”).
Delegates to Sprite.direction
positionInFence
Section titled “positionInFence”positionInFence(): voidClamp this sprite’s position to stay within the stage fence.
Delegates to Sprite.positionInFence
setDirection
Section titled “setDirection”setDirection(direction: number): voidPoint this sprite in the given direction (degrees).
Delegates to Sprite.direction
Used by
setRotationStyle
Section titled “setRotationStyle”setRotationStyle(style: symbol): voidSet how this sprite rotates when its direction changes.
Delegates to Sprite.rotationStyle
setX(x: number): voidSet this sprite’s x position.
Delegates to Sprite.x
setY(y: number): voidSet this sprite’s y position.
Delegates to Sprite.y
turnClockwise
Section titled “turnClockwise”turnClockwise(degrees: number): voidTurn this sprite clockwise by a number of degrees.
Delegates to Sprite.direction
turnCounterClockwise
Section titled “turnCounterClockwise”turnCounterClockwise(degrees: number): voidTurn this sprite counter-clockwise by a number of degrees.
Delegates to Sprite.direction