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.

on sprite kind update interval

Problem it solves

You want every enemy on screen to do something on a regular timer—like sync animations or take periodic damage—without writing a per-sprite timer for each one.

What this block does

Runs your code for every sprite of a given kind on a repeating interval, in milliseconds.

The block

Block ID: spriteutilonspritekindupdateinterval

on $sprite of kind $kind update every $interval ms block

Parameters

NameTypeDefaultMeaning
kindSprite kindThe kind of sprite to run the handler for
intervalnumber500How often to run, in ms

Example

spriteutils.onSpriteKindUpdateInterval(SpriteKind.Enemy, 500, function (sprite) {
    console.log("tick")
})

Add the extension

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