MakeCode Games!

A fan-made community library of MakeCode Arcade games. Visit MakeCode Arcade to make a game!

← Back to extensions

Tilemap A* Pathfinding

Smart pathfinding for tilemaps that lets sprites calculate routes around walls and follow paths automatically.

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

on $sprite of kind $kind completes path at $location block

Parameters

NameTypeDefaultMeaning
kindnumberSpriteKind.EnemyThe kind of sprite to listen for (e.g. SpriteKind.Enemy or SpriteKind.Player).
handler(sprite: Sprite, location: tiles.Location) => voidnullThe 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.