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 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

$sprite move to $location at speed $speed||and pause $doPause block

Parameters

NameTypeDefaultMeaning
spriteSpritemySpriteThe sprite to move
locationSprite / Location / PointWhere to move it to
speednumber100How fast to travel, in pixels per second
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.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.