Skip to content

Commit

Permalink
update on() example which was incorrect (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
dragoncoder047 authored Nov 11, 2024
1 parent f00a7d6 commit 744d459
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1233,17 +1233,21 @@ export interface KAPLAYCtx<
* })
*
* // 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)
* // by passing an event name, a tag, and a callback function
* // if you want any tag, use a tag of "*"
* on("talk", "npc", (npc, message) => {
* npc.add([
* text(message),
* pos(0, -50),
* lifespan(2),
* opacity(),
* ])
* })
* });
*
* 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)
* })
* // the trigger method on game objs can be used to trigger a custom event
* npc.trigger("talk", "Hello, KAPLAY!");
* });
*
* ```
* @group Events
Expand Down

0 comments on commit 744d459

Please sign in to comment.