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

Instance functions

Instances are generally plugin-defined. You should read the sources of a plugin to see how it is implemented. However, Construct 2 guarantees the presence of certain properties and functions. These common properties and functions are documented here. Note any properties or functions relating to objects in a layout (e.g. x, y) are not present in non-layout objects.

Common instance properties

inst.type
Reference to the instance's object type.
inst.uid (read-only)
The instance's unique ID. Construct 2 issues the first instance a UID of 0 and increments by 1 for each new instance created. UIDs must never change through the life of an object.
inst.instance_vars[]
Array of instance variables. Each element is an ordinary javascript value corresponding to the current value of the instance variable at that index.
inst.x
inst.y
The current position of the instance in the layer. If changed, you must call inst.set_bbox_changed().
inst.width
inst.height
The current size of the instance, in pixels. If changed, you must call inst.set_bbox_changed().
inst.angle
The current object angle, in radians. Not all objects support an angle, e.g. Text object. If changed, you must call inst.set_bbox_changed().
inst.opacity
The current object opacity, from 0 (transparent) to 1 (opaque). Not all objects use the opacity.
inst.hotspotX
inst.hotspotY
Current position of the hotspot, in texture co-ordinates (e.g. (0.5, 0.5) will be a centered hotspot).
inst.bbox
A cr.rect representing the instance's axis aligned bounding box. You must call inst.update_bbox() before using this property.
inst.bquad
A cr.quad representing the instance's bounding quad. You must call inst.update_bbox() before using this property.
inst.visible
A boolean indicating if the object is currently visible.
inst.layer
A reference to the layer the object is on, if a world object.
inst.behavior_insts[]
Array of instances of each behavior added to the object type.
inst.inst
In behavior instances only: this is the reference to the object instance your behavior should modify.

Common instance functions

inst.set_bbox_changed()
You must call this to indicate to Construct 2 that the object's bounding box has changed, after modifying the x, y, width, height or angle properties.
inst.update_bbox()
You must call this before accessing the bbox or bquad members of an instance. Otherwise, their values will be invalid.
inst.add_bbox_changed_callback(f)
Calls f(inst) whenever set_bbox_changed() is called on inst. Warning: this can cause a large performance overhead, so use with care.
inst.get_iid()
Get the Instance ID (IID). This is the zero-based index in the object type's instances array where this instance is located. Note: you must use this function to get the IID, since IIDs are lazily assigned.
inst.toString()
Overridden to return a string in the format "inst:Type[#]uid" e.g. "inst:Player[#]0".
Construct 2 Javascript SDK Manual 2020-06-05