ct represents the game engine itself, extended with modules and core libraries. The core lib contains of:
- ct.backgrounds for, well, managing backgrounds;
- ct.camera for viewport management;
- ct.emitters for particle systems;
- ct.inputs and ct.actions for handling user input;
- ct.res for loading resources;
- ct.rooms for switching and stacking multiple rooms (for UI, lighting, and gameplay, for example);
- ct.sound for playing and tweaking sound effects;
- ct.styles for reusing UI styles;
- ct.tilemaps for dynamically generating levels made of tiles;
- ct.timer for asynchronous events;
- ct.templates for creating, finding and managing templates and copies;
- ct.u for vector functions, among other utilities.
You will usually use the API above, as well as those APIs provided by ct.js modules.
By itself, ct.js is based on Pixi.js, an HTML5 graphics library. You can use its API if you feel ct.js' one is not enough.
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;
@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.
ct.deltaUi is similar to
ct.delta, but it ignores time scaling factors that can happen during slow-mo effects or game pause (see "Pausing a game" for examples).