Function

onCollide

(t1: Tag, t2: Tag, action: (a: GameObj, b: GameObj, col?: Collision) => void): KEventController

Register an event that runs once when 2 game objs with certain tags collides (required to have area() component).

param t1- The tag of the first game obj.

param t2- The tag of the second game obj.

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

onCollide("sun", "earth", () => {
    addExplosion()
})

returns The event controller.

since v2000.1

group Events

kaplay logo

Layer

Miscalenous