addChild method

void addChild (
  1. Node child
)

Adds a child to this node.

The same node cannot be added to multiple nodes.

addChild(new Sprite(myImage));

Implementation

void addChild(Node child) {
  assert(child != null);
  assert(child._parent == null);
  assert(_assertNonCircularAssignment(child));

  _childrenNeedSorting = true;
  _children.add(child);
  child._parent = this;
  child._spriteBox = this._spriteBox;
  _childrenLastAddedOrder += 1;
  child._addedOrder = _childrenLastAddedOrder;
  if (_spriteBox != null) _spriteBox._registerNode(child);
}