MakeCode Games!

A fan-made community library of MakeCode Arcade games. Visit MakeCode Arcade to make a game!

← Back to extensions

Sprite Utils

A grab-bag of sprite math and rendering helpers for MakeCode Arcade: distances, angles, movement, timers, and simple drawing.

move to

Problem it solves

You want a sprite to glide smoothly to a specific spot over a set amount of time, without hand-writing timers or velocity math.

What this block does

Moves a sprite to a location (a sprite, point, or tile location) over the given number of milliseconds. Optionally pauses your code until the move finishes. Only works for sprites without acceleration or friction.

The block

Block ID: spriteutilmoveto

$sprite move to $location over $time ms||and pause $doPause block

Parameters

NameTypeDefaultMeaning
spriteSpritemySpriteThe sprite to move
locationSprite / Location / PointWhere to move it to
timenumber100How long the move should take, in ms
doPausebooleanfalseOptionally wait for the move to finish before continuing

Example

let mySprite = sprites.create(img`.`, SpriteKind.Player)
let myEnemy = sprites.create(img`.`, SpriteKind.Enemy)
spriteutils.moveTo(mySprite, spriteutils.point(80, 60), 1000)

Add the extension

Add github:jwunderl/arcade-sprite-util to your project, or open: Import arcade-sprite-util.