public void pauseTarget(System.Object target) { tHashElement element = _targets.HASH_FIND_INT(target.GetHashCode()); if (element != null) { element.paused = true; } }
/** Schedules the 'update' selector for a given target with a given priority. * The 'update' selector will be called every frame. * The lower the priority, the earlier it is called. * @since v0.99.3 */ public void scheduleUpdate(System.Object target, int priority, bool paused) { tHashUpdateEntry hashElement = hashForUpdates.HASH_FIND_INT(target.GetHashCode()); if (hashElement != null) { if (CCDebug.COCOS2D_DEBUG >= 1) { NSUtils.Assert(hashElement.entry.obj.markedForDeletion, "CCScheduler: You can't re-schedule an 'update' selector'. Unschedule it first"); } // TODO : check if priority has changed! hashElement.entry.obj.markedForDeletion = false; return; } // most of the updates are going to be 0, that's way there // is an special list for updates with priority 0 if (priority == 0) { appendIn(updates0, target, paused); } else if (priority < 0) { priorityIn(updatesNeg, target, priority, paused); } else // priority > 0 { priorityIn(updatesPos, target, priority, paused); } }
/** The scheduled method will be called every 'interval' seconds. * If paused is YES, then it won't be called until it is resumed. * If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead. * If the selector is already scheduled, then only the interval parameter will be updated without re-scheduling it again. * repeat lets the action be repeated repeat + 1 times, use kCCRepeatForever to let the action run continuously * delay is the amount of time the action will wait before it'll start * * @since v0.99.3, repeat and delay added in v1.1 */ public void schedule(TICK_IMP selector, System.Object target, float interval, uint repeat, bool paused, float delay = 0) { NSUtils.Assert(selector != null, "Argument selector must be non-nil"); NSUtils.Assert(target != null, "Argument target must be non-nil"); tHashTimerEntry element = hashForTimers.HASH_FIND_INT(target.GetHashCode()); if (element == null) { element = new tHashTimerEntry(); element.target = target; hashForTimers.HASH_ADD_INT(target.GetHashCode(), element); // Is this the 1st element ? Then set the pause level to all the selectors of this target element.paused = paused; } else { NSUtils.Assert(element.paused == paused, "CCScheduler. Trying to schedule a selector with a pause value different than the target"); } if (element.timers == null) { element.timers = new List <CCTimer> (10); } else { var enumerator = element.timers.GetEnumerator(); while (enumerator.MoveNext()) { CCTimer timer = enumerator.Current; if (timer is CCTimerTargetSelector && selector == ((CCTimerTargetSelector)timer).selector) { CCDebug.Log("CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: {0:0.0000} to {1:0.0000}", timer.interval, interval); timer.interval = interval; return; } } } CCTimerTargetSelector timerSelector = new CCTimerTargetSelector(target, selector, interval, repeat, delay); element.timers.Add(timerSelector); }