on sprite of kind completes path
Problem it solves
You want an enemy in a tower defense game to deal damage to your base when it reaches the exit, or make an NPC talk once it arrives at its destination.
What this block does
Runs a block of code whenever any sprite of a specific kind reaches the final tile of its path. It gives you access to the sprite that finished and the tile location where it stopped.
The block
Parameters
| Name | Type | Default | Meaning |
|---|---|---|---|
| kind | number | SpriteKind.Enemy | The kind of sprite to listen for (e.g. SpriteKind.Enemy or SpriteKind.Player). |
| handler | (sprite: Sprite, location: tiles.Location) => void | null | The code to run when the path finishes, receiving the completed sprite and its final location. |
Example
scene.onPathCompletion(SpriteKind.Enemy, function (sprite, location) {
sprite.destroy()
info.changeLifeBy(-1)
})Add the extension
Add github:jwunderl/arcade-tilemap-a-star to your project, or open: Import arcade-tilemap-a-star.