Skip to content

Commit

Permalink
docs for on completed,
Browse files Browse the repository at this point in the history
  • Loading branch information
jwunderl committed Mar 10, 2021
1 parent 8aca7f3 commit b9a9390
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
38 changes: 38 additions & 0 deletions docs/on-path-completion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# on Path Completion

Set code to run when a sprite of the given kind has finished following it's path.

```sig
scene.onPathCompletion(null, null)
```

## Parameters

* **kind**: A kind of sprite to register an event for.
* **handler**: The code to run when a sprite finishes it's path.
>* **sprite**: The sprite that has completed it's Path.
>* **location**: The location at which the sprite has completed it's path.
## Example

Creates an event so when an enemy finishes it's path, the game end

```blocks
scene.onPathCompletion(SpriteKind.Enemy, function (sprite, location) {
game.over(false);
})
```

Creates an event so that a food sprite is destroyed and the location becomes a wall
when a path is completed.

```blocks
scene.onPathCompletion(SpriteKind.Food, function (sprite, location) {
sprite.destroy(effects.trail, 500)
tiles.setWallAt(location, true)
})
```

```package
arcade-tilemap-a-star=github:jwunderl/arcade-tilemap-a-star
```
2 changes: 1 addition & 1 deletion docs/sprite-is-following-path.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Returns true if the sprite is currently following a path,
and false otherwise

```sig
scene.spritePercentPathCompleted(null)
scene.spriteIsFollowingPath(null)
```

## Parameters
Expand Down
3 changes: 2 additions & 1 deletion pxt.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"docs/a-star.md",
"docs/follow-path.md",
"docs/sprite-percent-path-completed.md",
"docs/sprite-is-following-path.md"
"docs/sprite-is-following-path.md",
"docs/on-path-completion.md"
],
"testFiles": [
"tilemap.g.jres",
Expand Down

0 comments on commit b9a9390

Please sign in to comment.