Creating and Destroying Nodes

    Sometimes it is needed to dynamically clone the existing nodes in the scene, it can be done through the instantiate method. Example:

    Through the function, nodes can be destroyed. It is worth mentioning that the destroyed node will not be removed immediately, but will be executed uniformly after the logic update of the current frame is completed. When a node is destroyed, the node is in an invalid state. Use isValid to determine whether the current node has been destroyed. Example:

    In short, if a node is no longer used, destroy is right, there is no need to removeFromParent nor to set parent to .