Static
addGeneric single or multi-add function. Adds a single or an array of body(s), constraint(s) or composite(s) to the given composite.
Triggers beforeAdd
and afterAdd
events on the composite
.
A single or an array of body(s), constraint(s) or composite(s)
The original composite with the objects added
add
Static
addAdds a body to the given composite.
The original composite with the body added
addBody
Static
addAdds a composite to the given composite.
The original compositeA with the objects from compositeB added
addComposite
Static
addAdds a constraint to the given composite.
The original composite with the constraint added
addConstraint
Static
clearRemoves all bodies, constraints and composites from the given composite. Optionally clearing its children recursively.
clear
Static
createSee above, aliases for back compatibility only
Optional
bodies?: IBody[]An array of Body
that are direct children of this composite.
To add or remove bodies you should use Composite.add
and Composite.remove
methods rather than directly modifying this property.
If you wish to recursively find all descendants, you should use the Composite.allBodies
method.
[]
Optional
cache?: { allBodies?: IBody[] | null | undefined; allConstraints?: IConstraint[] | null | undefined; allComposites?: IComposite[] | null | undefined; }An object used for storing cached results for performance reasons. This is used internally only and is automatically managed.
Optional
composites?: IComposite[]An array of Composite
that are direct children of this composite.
To add or remove composites you should use Composite.add
and Composite.remove
methods rather than directly modifying this property.
If you wish to recursively find all descendants, you should use the Composite.allComposites
method.
[]
Optional
constraints?: IConstraint[]An array of Constraint
that are direct children of this composite.
To add or remove constraints you should use Composite.add
and Composite.remove
methods rather than directly modifying this property.
If you wish to recursively find all descendants, you should use the Composite.allConstraints
method.
[]
Optional
events?: { beforeAdd?: Function[] | undefined; afterAdd?: Function[] | undefined; beforeRemove?: Function[] | undefined; afterRemove?: Function[] | undefined; }Optional
gravity?: { x?: number | undefined; y?: number | undefined; scale?: number | undefined; }Optional
id?: numberAn integer Number
uniquely identifying number generated in Composite.create
by Common.nextId
.
Optional
isA flag that specifies whether the composite has been modified during the current step. This is automatically managed when bodies, constraints or composites are added or removed.
false
Optional
label?: stringAn arbitrary String
name to help the user identify and manage composites.
"Composite"
Optional
parent?: null | ({ id?: number | undefined; type?: "composite" | undefined; label?: string | undefined; isModified?: boolean | undefined; parent?: ... | null | undefined; bodies?: IBody[] | undefined; ... 5 more ...; gravity?: { ...; } | undefined; })The Composite
that is the parent of this composite. It is automatically managed by the Matter.Composite
methods.
null
Optional
plugin?: ({}) | ({ name?: string | undefined; version?: string | undefined; for?: string | undefined; uses?: string[] | undefined; install?: { apply?: {} | undefined; call?: {} | undefined; bind?: {} | undefined; ... 6 more ...; [Symbol.hasInstance]?: {} | undefined; } | undefined; _warned?: boolean | undefined; })An object reserved for storing plugin-specific properties.
{}
Optional
type?: "composite"A String
denoting the type of object.
Static
removeGeneric remove function. Removes one or many body(s), constraint(s) or a composite(s) to the given composite.
Optionally searching its children recursively.
Triggers beforeRemove
and afterRemove
events on the composite
.
The original composite with the objects removed
remove
Generated using TypeDoc
This module has now been replaced by
Matter.Composite
.All usage should be migrated to the equivalent functions found on
Matter.Composite
. For exampleWorld.add(world, body)
now becomesComposite.add(world, body)
.The property
world.gravity
has been moved toengine.gravity
.For back-compatibility purposes this module will remain as a direct alias to
Matter.Composite
in the short term during migration. Eventually this alias module will be marked as deprecated and then later removed in a future release.