Construct 3 icon

Construct 3

Documentation

WorldInstance script interface

Ashley's avatar
Medal
Construct Team Founder
Published 28 May, 2019
313 words
~1-2 mins

The IWorldInstance script interface represents a single instance of an object type (represented by IObjectClass) that appears in a layout. It derives from the IInstance script interface.

Many objects return a more specific class deriving from IInstance or IWorldInstance to add APIs specific to the plugin. See the Plugin interfaces reference for more information.

WorldInstance APIs

layout

An ILayout interface representing the layout the instance is on.

layer

An ILayer interface representing the layer the instance is on.

x

y

The position of this instance, in layout co-ordinates.

width

height

The size of this instance, in layout co-ordinates.

angle

The angle of the instance in radians. If this is changed, angleDegrees updates accordingly.

angleDegrees

The angle of the instance in degrees. If this is changed, angle updates accordingly.

isVisible

A boolean indicating whether the instance is visible in the layout.

opacity

The opacity of the instance, as a floating point number in the range [0, 1], where 0 is fully transparent and 1 is fully opaque.

containsPoint(x, y)

Test if a point intersects this instance, using its collision polygon if any, and return a boolean indicating if the point is inside the instance's collision area.

testOverlap(wi)

Test if this instance overlaps another world instance given by an IWorldInstance, returning true if they overlap, else false. This uses the object's collision polygons if any. If either instance has collisions disabled, this will always return false.

testOverlapSolid()

Test if this instance overlaps any instance with the Solid behavior. This returns the instance interface class for the first instance with the solid behavior that was found to overlap this instance, or null if none. This uses the object's collision polygons if any and respects solid collision filtering.