follow path
Problem it solves
You want a sprite to automatically travel along a planned path from checkpoint to checkpoint, navigating around walls along the way.
What this block does
Guides a sprite through each tile location in the path at the specified speed. Note that this function pauses code execution in its current thread until the sprite arrives at the final location or stops.
The block
Parameters
| Name | Type | Default | Meaning |
|---|---|---|---|
| sprite | Sprite | mySprite | The sprite that will move along the path. |
| path | TilemapPath | path | The path object for the sprite to follow. |
| speed | number | 100 | How fast the sprite moves in pixels per second. |
Example
let guard = sprites.create(img`.`, SpriteKind.Enemy) let myPath = TilemapPath.create_path([tiles.getTileLocation(2, 2), tiles.getTileLocation(8, 2)]) TilemapPath.follow_path(guard, myPath, 60)
Add the extension
Add github:UnsignedArduino/TilemapPath to your project, or open: Import TilemapPath.