Construct 2 has been officially retired. Now you should upgrade to Construct 3.

Runtime reference

The runtime object represents a single instance of a user's project running in the browser. It is usually accessed via this.runtime from an object instance. Remember only documented properties and methods should be used.

Runtime properties

runtime.canvas (read-only)
The canvas element in the page the project is running on.
runtime.width (read-only)
runtime.height (read-only)
The size of the canvas element in the page. This can change at runtime if Fullscreen in browser is enabled and the user resizes the browser window.
runtime.redraw (write-only)
This must be set to true whenever anything is done that affects how the project is rendered. If redraw remains false, the canvas is assumed not to have changed and will not be redrawn.
An array of all the plugins used in the project.
An array of all the object types in the project.
An array of all the layouts in the project.
An array of all the event sheets in the project.
runtime.wait_for_textures[] (write-only)
Add a HTML Image() class to this array during loading, and the loader will wait for it to finish downloading before starting the runtime. See Tiled Background for an example.
The current time scale.
runtime.kahanTime.sum (read-only)
The current in-game time, in seconds, with timescaling applied.
The number of ticks elapsed since the start of the game.
runtime.changelayout (write-only)
Set to a reference to a layout object and the following tick the runtime will execute Go to layout on that layout.
runtime.running_layout (read-only)
A reference to the current layout that is running.
runtime.files_subfolder (read-only)
The subfolder where project files are held.
The runtime is sealed. You may store any additional properties you need in this object.
runtime.start_time (read-only)
Set to date.getTime() on starting the first layout.

Runtime functions

Call to have the runtime call tick() on your plugin instance. You must define a tick() method in the instance's prototype. Note: behaviors are automatically ticked.
Return delta-time, in seconds, with time scaling applied. You must pass an instance to get dt for, to maintain compatibility with the Set object timescale feature.
Calls f(inst) whenever an instance is destroyed.
Destroys the given instance.
runtime.createInstance(type, layer)
Create a new instance of the object type on the given layer. Returns a reference to the created instance.
Get a layer by name, case insensitive, or null if not found.
Get a layer by zero-based index, or null if out of bounds.
runtime.testAndSelectCanvasPointOverlap(type, x, y, inverted)
Pick any instances of type that overlap the point (x, y) in canvas co-ordinates. Pass the condition's inverted state for correct behavior. See the Mouse object for an example.
runtime.testOverlap(a, b)
Return true if the two given instances are overlapping.
Returns an instance with the Solid attribute if inst is overlapping a solid, else null.
runtime.pushOutSolid(inst, xdir, ydir, dist)
Pushes inst the distance given by xdir and ydir up to dist, until inst is not overlapping any solid. If inst finishes overlapping a solid, it is put back to its original position and false is returned. Otherwise, true is returned.
runtime.pushOutSolidNearest(inst, max_dist)
Pushes inst in an 8-direction spiral pattern up to max_dist pixels away until it is no longer overlapping a solid. If inst is still overlapping a solid by max_dist, it is returned to its original position and false is returned. Otherwise, true is returned.
runtime.trigger(method, inst)
Trigger the condition specified by method, with the object inst triggering. The condition must specify cf_trigger and not cf_faketrigger. If triggering your own plugin's trigger, pass this for inst. method must specify the plugin routine in the form:

Returns the current condition. Only valid in condition methods.
Returns the current action. Only valid in action methods.
Return the current event "stack frame". This can be used to determine the current event via runtime.getCurrentEventStack().current_event.
Construct 2 Javascript SDK Manual 2020-06-05