IObjectType interface

Ashley's avatar
Medal
Construct Team Founder
Published 14 Nov, 2017
277 words
~1-2 mins

The IObjectType interface represents an object type in Construct. It derives from IObjectClass.

Methods

GetImage()

Return an IAnimationFrame representing the object type's image. The plugin must have specified SetHasImage(true) in IPluginInfo.

EditImage()

Open the Animations Editor in Construct to edit the object's image. The plugin must have specified SetHasImage(true).

GetAnimations()

Return an array of IAnimation representing the animations in the object type. Note this is only applicable to animated plugin types, e.g. Sprite.

AddAnimation(animName, frameBlob, frameWidth, frameHeight)

Add a new animation to the object type. The object type's plugin must be animated (e.g. the Sprite plugin). Animations must have at least one frame, so this method also adds an animation frame. The frameBlob, frameWidth and frameHeight parameters are all optional: if they are omitted, Construct will add a default empty animation frame. If they are provided they are interpreted the same way as IAnimation.AddFrame(); see the linked documentation for more details. The call returns a promise that resolves with the newly created IAnimation.

CreateWorldInstance(layer)

Create a new instance from this object type, and add it to the given ILayer. Returns a new IWorldInstance interface representing the new instance. Note this method is only applicable to "world" type plugins.

IsInContainer()

Return a boolean indicating if the object type belongs to a container.

GetContainer()

Return the IContainer the object type belongs to if any, else null.

CreateContainer(initialObjectTypes)

Create a new container using an array of IObjectType for the members of the container. The array must include the IObjectType this call is made on, must contain at least two elements, and the object type must not already be in a container. Returns an IContainer representing the created container.