Function

onClick

(tag: Tag, action: (a: GameObj) => void): KEventController

Register an event that runs when game objs with certain tags are clicked (required to have the area() component).

param tag- The tag to listen for.

param action- The function to run when the event is triggered.

// click on any "chest" to open
onClick("chest", (chest) => chest.open())

returns The event controller.

since v2000.1

group Input

Function

onClick

(action: () => void): KEventController

Register an event that runs when users clicks.

param action- The function to run when the event is triggered.

// click on anywhere to go to "game" scene
onClick(() => go("game"));

returns The event controller.

since v2000.1

group Events

kaplay logo

Layer

Miscalenous