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
Parameters
| Name | Type | Default | Meaning |
|---|---|---|---|
| sprite | Sprite | mySprite | The sprite to move |
| location | Sprite / Location / Point | — | Where to move it to |
| time | number | 100 | How long the move should take, in ms |
| doPause | boolean | false | Optionally 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.