BBGamelib.CCScheduler.schedule C# (CSharp) Method

schedule() public method

public schedule ( TICK_IMP selector, System target, float interval, uint repeat, bool paused, float delay ) : void
selector TICK_IMP
target System
interval float
repeat uint
paused bool
delay float
return void
		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);
		}

Usage Example

コード例 #1
0
        /**
         * repeat will execute the action repeat + 1 times, for a continues action use kCCRepeatForever
         * delay is the amount of time the action will wait before execution
         */
        public void schedule(TICK_IMP selector, float interval = 0, uint repeat = CCScheduler.kCCRepeatForever, float delay = 0)
        {
            NSUtils.Assert(selector != null, "Argument must be non-nil");
            NSUtils.Assert(FloatUtils.EB(interval, 0), "Arguemnt must be positive");


            _scheduler.schedule(selector, this, interval, repeat, !_isRunning, delay);
        }