move to at speed
Problem it solves
You know how fast you want a sprite to travel, but not how long the trip should take, so `move to` isn't the right fit.
What this block does
Moves a sprite to a location (a sprite, point, or tile location) at a fixed speed. Optionally pauses your code until the move finishes. Only works for sprites without acceleration or friction.
The block
Block ID: spriteutilmovetoatspeed
Parameters
| Name | Type | Default | Meaning |
|---|---|---|---|
| sprite | Sprite | mySprite | The sprite to move |
| location | Sprite / Location / Point | — | Where to move it to |
| speed | number | 100 | How fast to travel, in pixels per second |
| 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.moveToAtSpeed(mySprite, spriteutils.point(80, 60), 100)
Add the extension
Add github:jwunderl/arcade-sprite-util to your project, or open: Import arcade-sprite-util.