Group#add()

add(child, silent, index) → {DisplayObject}

Adds an existing object as the top child in this group.

The child is automatically added to the top of the group, and is displayed above every previous child.

Or if the optional index is specified, the child is added at the location specified by the index value,
this allows you to control child ordering.

If the child was already in this Group, it is simply returned, and nothing else happens to it.

If Group.enableBody is set, then a physics body will be created on the object, so long as one does not already exist.

If Group.inputEnableChildren is set, then an Input Handler will be created on the object, so long as one does not already exist.

Use addAt to control where a child is added. Use create to create and add a new child.

Parameters
Name Type Argument Default Description
child DisplayObject

The display object to add as a child.

silent boolean <optional>
false

If true the child will not dispatch the onAddedToGroup event.

index integer <optional>

The index within the group to insert the child to. Where 0 is the bottom of the Group.

Returns

The child that was added to the group.

Source code: core/Group.js (Line 341)
doc_phaser
2017-02-14 10:50:38
Comments
Leave a Comment

Please login to continue.