is destroyed
Problem it solves
You saved a reference to a sprite (like an enemy or a bullet), but later code might run after that sprite has already been destroyed, and touching a destroyed sprite can crash your game.
What this block does
Checks whether a sprite no longer exists or has already been destroyed, so you can safely skip code that would otherwise touch it.
The block
Block ID: spriteutilextisdestroyed
Parameters
| Name | Type | Default | Meaning |
|---|---|---|---|
| sprite | Sprite | mySprite | The sprite to check. |
Returns
boolean — true if the sprite is missing or destroyed.
Example
let mySprite = sprites.create(img`.`, SpriteKind.Player)
let myEnemy = sprites.create(img`.`, SpriteKind.Enemy)
if (spriteutils.isDestroyed(myEnemy)) {
console.log("enemy is gone")
}Add the extension
Add github:jwunderl/arcade-sprite-util to your project, or open: Import arcade-sprite-util.