WorldInfo class represents the state of an instance in the "world" (i.e. the Layout it is in). This includes information like its position, size, angle, Z order, layer and so on.
Only "world" type plugin instances have an associated
WorldInfo. It is typically obtained by using the Instance
Modifying geometric properties
For performance reasons, changing the X, Y, angle, width, height or origin does not update the corresponding bounding box, which is stored separately. If any of these properties are changed, you must call
SetBboxChanged() afterwards to ensure the runtime re-calculates the bounding box.
- Return the associated Instance that this
WorldInfo represents state for.
- SetXY(x, y)
- Set and get the position of the instance in layout co-ordinates.
- OffsetXY(x, y)
- Add to the X and Y components of the instance's position. For example
OffsetX(5) is equivalent to
SetX(GetX() + 5).
- SetSize(w, h)
- Set and get the width and height of the instance in layout co-ordinates.
- Set and get the angle of the instance in radians. Use
C3.toRadians() to convert from degrees to radians.
- Set and get the origin of the instance as a normalized position in the [0,1] range, i.e. 0.5 is the middle.
- Mark the instance's bounding box as having been changed. Call this after altering the position, size, angle or origin of the instance.
- Return a C3.Rect representing the axis-aligned bounding box of the instance in layout co-ordinates.
- Return a C3.Quad representing the bounding quad of the instance in layout co-ordinates, which is essentially the rotated bounding box.
- Set and get the opacity of the instance in the [0,1] range. 0 is fully transparent and 1 is opaque. This changes the alpha component of the instance color.
- Set the RGB components of the instance color. This applies a built-in color multiply effect which appears like a tint. As with opacity, color values are in the [0,1] range. The default is RGB 1,1,1 (white) which means the instance appears with normal colors. Pass a C3.Color as the parameter. The runtime internally uses premultiplied alpha for best rendering quality; in this method the RGB values do not need to be premultiplied with the alpha (opacity) value, since it will apply the premultiplication for you.
- Get the instance color as a read-only C3.Color, either without or with premultiplied alpha (respectively). The instance color includes the opacity in the alpha channel.
true if the instance color RGBA value equals (1,1,1,1), else false.
- Set and get the instance blend mode, as an index in to the dropdown list used in Construct's Blend mode property. E.g. 0 is "normal", 1 is "additive", etc.
- Get the Layer the instance is currently on.
- Get the Layout the instance currently belongs to.
Set and get the visible state for the instance. This is a boolean that hides the instance when set to
- Set and get a boolean indicating whether collisions are enabled for this instance.
- ContainsPoint(x, y)
- Test if a point in layout co-ordinates intersects this instance, respecting its collision polygon and collisions enabled flag.
Mesh distortion methods
- CreateMesh(hsize, vsize)
- Create a mesh for deforming the appearance of the object with the given number of mesh points horizontally and vertically. The minimum size is 2.
- Releases any mesh that has been created, reverting back to default rendering of the object with no mesh distortion. Ignored if no mesh created.
- Return a boolean indicating whether a mesh has been created for this object.
- SetMeshPoint(col, row, opts)
- Alter a given point in a created mesh given by its zero-based column and row.
opts is an object that may specify the following properties:
Note: this method returns a boolean indicating whether you must subsequently call
mode: a string of
"absolute" (default) or
"relative", determining how to interpret the
y: the mesh point position offset, in normalized co-ordinates [0, 1] across the object size. These are allowed to go outside the object bounds. In relative mode these are added to the mesh point's current position.
v: the texture co-ordinate for the mesh point, in normalized co-ordinates [0, 1]. These are not allowed to go outside the object bounds. These can be omitted, or in absolute mode be set to -1, to indicate not to change the texture co-ordinate from the default.
SetBboxChanged() to apply the change. This allows all points in the mesh to be efficiently updated without unnecessarily repeatedly calling
Z order methods
- Move the instance to the top or bottom of the Z order on its current layer.
- Move the instance in the Z order to the given Layer. If the same layer it is currently on is specified, the call is ignored. If the instance is moved to a new layer, it is inserted to the top of the Z order on that layer.
- ZOrderMoveAdjacentToInstance(otherInst, isOnTop)
- Move the instance in the Z order to be adjacent to the Instance
otherInst (note this is passed as an
Instance, not a
isOnTop is true, this instance will be moved directly on top of
otherInst in the Z order; otherwise it will be directly beneath. This method may move the instance to a different layer, since it will move it to the same layer as
otherInst is on.
Addon SDK Manual
You are here:
Search this manual:
This manual entry was last updated on 16 Nov, 2020 at 18:05