ct represents the drawing canvas itself, extended with modules and core libraries. But let's talk a bit about how it all works.

Event sequence

These events are always executed in the following order:

  1. oncreate event, which is emitted when a user starts a game or navigates to a new room;
  2. main game loop occurs:
    1. onstep event is emitted for all the copies in the room;
    2. onstep event for current room is called;
    3. ondestroy is called for all the copies marked to be killed;
    4. all the copies are reordered, the canvas is cleaned here;
    5. ondraw is called for all the copies;
    6. ondraw is called for a room;
    7. input events are cleared. Waiting for a new game loop iteration.
  3. When a user moves to a new room, an ondestroy event is called for current (previous) room.

Methods and properties

ct.newspeed(fps: Number)

Sets new max frames per second.


A read-only variable representing the current max FPS.


The drawing context of the main canvas.


The drawing canvas of the game.


Returns the metadata that you supplied inside the ct.js editor, such as author, site, version and name.

Last Updated: 10/27/2018, 10:47:49 AM