ct represents the game engine itself, extended with modules and core libraries. But let's talk a bit about how it all works.
These events are always executed in the following order:
oncreateevent, which is emitted when a user starts a game or navigates to a new room;
oncreateis applied for each copy;
- then the main game loop starts:
onstepevent is emitted for all the copies in the room;
onstepevent for current room is called;
ondestroyis called for all the copies marked to be
- all the copies are reordered then;
ondrawis called for all the copies;
ondrawis called for a room;
- input events are cleared. Waiting for a new game loop iteration.
- When a user moves to a new room, an
onleaveevent is called for the latest room.
Methods and properties
The Pixi.js application of the game.
The game's root stage.
Returns the metadata that you supplied inside the ct.js editor, such as
A multiplier that shows how much a current frame differs from the target FPS. It will change depending on game's performance. For example, it will be
2 at 30 FPS, as a target one is 60 FPS, and it will be
1 at completely smooth target framerate.
You can use this delta while designing movement, so things move uniformly at any framerate, e.g.:
this.x += 10 * ct.delta;
But this delta is mostly useful while designing complex or logic-driven movement, as the default movement system already takes
ct.delta into account.