on(eventName,func) , method of game

Add a listener function to a named event.

The function gets called when the event is triggered.

Parameters:
name type description
eventName string a standard or custom event name. See ??
func function a Javascript function that takes an Event.
// Add a Circle when the player entered the game.

UB.game.on("playerJoined", addCircle);


function addCircle(event) {
UB.scene.addCircle({x: 200, y: 300, radius: 80});
}

See all methods of the api.