Skip to content

GCompound extends GObject

The GCompound defines a graphical object that consists of a collection of other graphical objects. Once assembled, the internal objects can be manipulated as a unit.

Factory Functions

function GCompound()
function GCompound(x, y)
Creates a new GCompound, optionally moving the compound's origin to (x, y).

Methods

function GCompound::add(gObject[, x=gObject.getX(), y=gObject.getY()])
Adds the given gObject to the compound. If x and y are specified, the gObject's x and y values are overwritten; otherwise, they're used instead.
function GCompound::remove(gObject)
Removes the given @P.gObject from the compound.
function GCompound::removeAll()
Removes all GObjects from this GCompound.
function GCompound::getElementCount()
Returns: The number of GObjects stored in this GCompound.
function GCompound::getElement(index)
Returns: The GObject at the specified index (where index 0 was the first GObject added to the GCompound/the GObject farthest back, and the last index is the most recently added/most on top GObject).
function GCompound::getElementAt(x, y)
Gets the topmost (i.e. most recently-added) GObject at the specified x/y coordinates.
Returns: The found GObject, or null if there's not an object at the specified coordinates.

Note

If you need to access elements in a GCompound, it's recommended to append them as additional fields, rather than use GCompound::getElementAt or GCompound::getElement.