Skip to main content

excaliburjs logoLifecycle Events

When your game is loaded into a user's feed on xelly.games, your install function is called. But your game should also respond to certain lifecycle events:

xelly:enter

While scrolling their feed, xelly.games users tap (or, on desktops, click) to "enter" a game and start playing it.

xelly:enter is emitted on the game Engine by the platform when the user first taps or click on the game in their feed.

In the breakout example game this is used to start the ball moving when the user enters the game for the first time:

    ...
engine.once('xelly:enter', ((coords: GlobalCoordinates) => {
if (coords.worldPos.x < engine.drawWidth / 2) {
ball.start('left');
} else {
ball.start('right');
}
}) as Handler<any>);
...

xelly:terminate

This events is emitted by your game on the game Engine when the game has reached a terminal state — such as a win or loss state.

    ...
// always emit 'xelly:terminate' when the game is over, win or lose
if (isGameWon) {
showMessagePanel('You win!');
engine.emit('xelly:terminate');
} else if (isGameLost) {
showMessagePanel('You lose!');
engine.emit('xelly:terminate');
}
...
warning

If your game is a turn-based or realtime game, you must emit this event when the game reaches a win or loss state!

This is how the xelly.games platform knows when to enable certain controls that allow your user to restart/replay the game, for example.

xelly:start

This event is emitted on the game Engine by the platform when the game has finished loading and initializing (but before a user taps to enter the game play). This event is not commonly used, so you can generally ignore it if you don't have a good use for it.