on sprite update interval
Problem it solves
You want a sprite to do something repeatedly—like fire a projectile or check its health—without cluttering the main game update loop with your own timer.
What this block does
Runs your code for a specific sprite on a repeating interval, in milliseconds.
The block
Block ID: spriteutilonspriteupdateinterval
Parameters
| Name | Type | Default | Meaning |
|---|---|---|---|
| target | Sprite | mySprite | The sprite to run the handler for |
| interval | number | 500 | How often to run, in ms |
Example
let mySprite = sprites.create(img`.`, SpriteKind.Player)
let myEnemy = sprites.create(img`.`, SpriteKind.Enemy)
spriteutils.onSpriteUpdateInterval(mySprite, 500, function (sprite) {
console.log("tick")
})Add the extension
Add github:jwunderl/arcade-sprite-util to your project, or open: Import arcade-sprite-util.