Phaser API Documentation

replace(oldChild, newChild, [destroyChild])


Replaces a Game Object in this Container with the new Game Object. The new Game Object cannot already be a child of this Container.


name type arguments Default description
oldChild Phaser.GameObjects.GameObject

The Game Object in this Container that will be replaced.

newChild Phaser.GameObjects.GameObject

The Game Object to be added to this Container.

destroyChild boolean <optional> false

Optionally call destroy on the Game Object if successfully removed from this Container.


This Container instance.

Since: 3.4.0