Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Commit

Permalink
Improved docs regarding custom events usage (#842)
Browse files Browse the repository at this point in the history
* Improved docs regarding custom events usage

* fixed formatting

* addressed feedback

* addressed feedback again

* fixed spacing issue
  • Loading branch information
JSLegendDev authored Apr 5, 2024
1 parent ab2b3d6 commit b77477e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,20 @@ export interface KaboomCtx {
* destroy(bomb)
* addKaboom(bomb.pos)
* })
*
* // a custom event can be defined manually
* // by passing a name and a callback function
* on("talk", (message, posX, posY) => {
* add([
* text(message),
* pos(posX, posY - 100)
* ])
* })
* onKeyPress("space", () => {
* // the trigger method on game objs can be used to trigger a custom event
* npc.trigger("talk", "Hello World!", npc.pos.x, npc.pos.y)
* })
*
* ```
*/
on(event: string, tag: Tag, action: (obj: GameObj, ...args: any) => void): EventController,
Expand Down

0 comments on commit b77477e

Please sign in to comment.