sprite follow path
Problem it solves
You generated a path using pathfinding and now you want an enemy or companion sprite to smoothly walk along that route.
What this block does
Makes a sprite move through an array of tile locations one by one at a specified speed. If the sprite starts inside a wall or slightly off the path, it navigates or teleports to the nearest path tile before continuing.
The block
Parameters
| Name | Type | Default | Meaning |
|---|---|---|---|
| sprite | Sprite | mySprite | The sprite that should follow the path. |
| path | tiles.Location[] | locationTiles | The list of tile locations the sprite will move through. |
| speed | number | 50 | The movement speed in pixels per second. |
Example
let mySprite = sprites.create(img`.`, SpriteKind.Enemy) let myPath = scene.aStar(tiles.getTileLocation(0, 0), tiles.getTileLocation(9, 7)) scene.followPath(mySprite, myPath, 50)
Add the extension
Add github:jwunderl/arcade-tilemap-a-star to your project, or open: Import arcade-tilemap-a-star.