private void _detachChild(Node child, bool doCleanup) { // IMPORTANT: // -1st do onExit // -2nd cleanup if (this.IsRunning) { child.onExit(); } // If you don't do cleanup, the child's actions will not get removed and the // its scheduledSelectors_ dict will not get released! if (doCleanup) { child.Cleanup(); } // set parent nil at the end child.Parent = null; this.Children.Remove(child); }