Пример #1
0
        public void RemoveTargetWithActionForControlEvent(object target, Action <object, CCControlEvent> action, CCControlEvent controlEvent)
        {
            // Retrieve all invocations for the given control event
            //<CCInvocation*>
            CCRawList <CCInvocation> eventInvocationList = DispatchListforControlEvent(controlEvent);

            //remove all invocations if the target and action are null
            if (target == null && action == null)
            {
                //remove objects
                eventInvocationList.Clear();
            }
            else
            {
                //normally we would use a predicate, but this won't work here. Have to do it manually
                foreach (CCInvocation invocation in eventInvocationList)
                {
                    bool shouldBeRemoved = true;
                    if (target != null)
                    {
                        shouldBeRemoved = (target == invocation.Target);
                    }
                    if (action != null)
                    {
                        shouldBeRemoved = (shouldBeRemoved && (action == invocation.Action));
                    }
                    // Remove the corresponding invocation object
                    if (shouldBeRemoved)
                    {
                        eventInvocationList.Remove(invocation);
                    }
                }
            }
        }
Пример #2
0
        private void DetachChild(CCNode child, bool doCleanup)
        {
            // IMPORTANT:
            //  -1st do onExit
            //  -2nd cleanup
            if (m_bRunning)
            {
                child.OnExitTransitionDidStart();
                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;

            m_pChildren.Remove(child);
        }