From 744d459baaa9d3a4a37b1c91986b1768e6752aa0 Mon Sep 17 00:00:00 2001 From: dragoncoder047 <101021094+dragoncoder047@users.noreply.github.com> Date: Mon, 11 Nov 2024 11:33:58 -0500 Subject: [PATCH] update on() example which was incorrect (#506) --- src/types.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/types.ts b/src/types.ts index 2bc8c55c..fb2f8a97 100644 --- a/src/types.ts +++ b/src/types.ts @@ -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