This object manages your rooms and current view (camera).
Methods and properties
Calls the latest room's
onleave event and moves to a new room.
Destroys all the existing copies in the room.
The current room's object.
Existing rooms to switch to.
A function that is called by a room to create its copies, backgrounds and tiles on load. It is mostly an internal function that is not intended for use in ct.IDE, but you still can use this method to add copies from one room to existing one. The method returns an array of all the created copies, including tile layers and backgrounds. Example:
this.interfaceCopies = ct.rooms.make.apply(ct.rooms.templates.MainInterface);
Managing current viewport
You can manage the viewport anytime by editing properties listed below of
ct.room object. You can also use
this keyword in room's events.
Current horizontal and vertical shift of the view.
You can set a copy to follow here, so the camera moves to it automatically.
Horizontal and vertical padding from the edges of the canvas, within which the camera moves.
// Place this code, e.g, to your hero's `OnCreate` code var room = ct.room; room.follow = this; // Follow the hero so it is always at the center of the screen room.borderX = room.viewWidth / 2; room.borderY = room.viewHeight / 2;
When set to
true, the followed copy will always stay in the middle of the viewport. This parameter has a higher priority over
A value between 0 and 1. Defines how fast a room reacts to a followed copy's movement.
0 means instant camera movement, higher values mean a more smooth movement.
Shifts the camera so that it stays above/below/etc the followed copy.