IObjectType script interface
The IObjectType
script interface represents an object type in the project, e.g. a Sprite object type. An object type can have multiple instances created, which are represented by the IWorldInstance script interface if it appears in a layout, otherwise the IInstance interface.
IObjectType
derives from IObjectClass which is a base class shared with families (IFamily).
Getting an IObjectType
References to the project's object types are typically accessed through the IRuntime interface objects
property. For example runtime.objects.Sprite
would refer to the IObjectType
interface for the Sprite object type, assuming one was added to the project.
Examples
The following examples demonstrate using some features of IObjectType
:
Object type APIs
- setInstanceClass(Class)
- Set a custom class to be used to represent instances of this object type. The class must derive from the default class. This can only be called in
runOnStartup
, before any instances have been created. For more information see the guide on subclassing instances.
- createInstance(layerNameOrIndex, x, y, createHierarchy, template)
- Create a new instance of the object type at a position. The layer to create on is specified either by a case-insensitive string of the layer name or its zero-based index. The position is given in layout co-ordinates. If
createHierarchy
is true, all children of the created instance in the scene-graph hierarchy will also be created automatically with their connections in place. If template
is a valid template name then the new instance will be based on the template rather than an arbitrary instance. The return value is the script interface for the created instance.
- getAllFamilies()
- Return an array of IFamily listing all the families this object type belongs to.
- *families()
- Iterates over all the families this object type belongs to (as
IFamily
).
- isInFamily(family)
- Returns a boolean indicating if this object type belongs to the specified
IFamily
.
Construct 3 Manual
Construct.net
2025-05-21
2025-05-21
You are here:
Search this manual:
This manual entry was last updated on 21 May, 2025 at 13:00