Class cc.Scheduler
Extends
cc.Class.
Defined in: CCScheduler.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Scheduler is responsible of triggering the scheduled callbacks. |
Method Attributes | Method Name and Description |
---|---|
ctor()
Constructor
|
|
returns time scale of scheduler
|
|
isTargetPaused(target)
Returns whether or not the target is paused
|
|
Pause all selectors from all targets. |
|
pauseAllTargetsWithMinPriority(minPriority)
Pause all selectors from all targets with a minimum priority.
|
|
pauseTarget(target)
Pauses the target. |
|
resumeTarget(target)
Resumes the target.
|
|
resumeTargets(targetsToResume)
Resume selectors on a set of targets.
|
|
scheduleCallbackForTarget(target, callback_fn, interval, repeat, delay, paused)
The scheduled method will be called every 'interval' seconds. |
|
scheduleUpdateForTarget(target, priority, paused)
Schedules the 'update' callback_fn for a given target with a given priority. |
|
setTimeScale(timeScale)
Modifies the time of all scheduled callbacks. |
|
Unschedules all function callbacks from all targets. |
|
unscheduleAllCallbacksForTarget(target)
Unschedules all function callbacks for a given target.
|
|
unscheduleAllCallbacksWithMinPriority(minPriority)
Unschedules all function callbacks from all targets with a minimum priority. |
|
unscheduleCallbackForTarget(target, callback_fn)
Unschedule a callback function for a given target. |
|
unscheduleUpdateForTarget(target)
Unschedules the update callback function for a given target
|
|
update(dt)
'update' the scheduler.
|
Scheduler is responsible of triggering the scheduled callbacks.
You should not use NSTimer. Instead use this class.
There are 2 different types of callbacks (selectors):
- update selector: the 'update' selector will be called every frame. You can customize the priority.
- custom selector: A custom selector will be called every frame, or with a custom interval of time
The 'custom selectors' should be avoided when possible. It is faster, and consumes less memory to use the 'update selector'. *
//register a schedule to scheduler cc.Director.getInstance().getScheduler().scheduleSelector(selector, this, interval, !this._isRunning);
- Returns:
- {Number}
- Parameters:
- {cc.Class} target
- Returns:
- {Boolean}
Pause all selectors from all targets.
You should NEVER call this method, unless you know what you are doing.
You should only call this with kCCPriorityNonSystemMin or higher.
- Parameters:
- minPriority
Pauses the target.
All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.
If the target is not present, nothing happens.
- Parameters:
- {cc.Class} target
The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.
If the target is not present, nothing happens.
- Parameters:
- {cc.Class} target
This can be useful for undoing a call to pauseAllCallbacks.
- Parameters:
- targetsToResume
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 callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
repeat let the action be repeated repeat + 1 times, use cc.REPEAT_FOREVER to let the action run continuously
delay is the amount of time the action will wait before it'll start
//register a schedule to scheduler cc.Director.getInstance().getScheduler().scheduleCallbackForTarget(function, this, interval, repeat, delay, !this._isRunning );
- Parameters:
- {cc.Class} target
- {function} callback_fn
- {Number} interval
- {Number} repeat
- {Number} delay
- {Boolean} paused
Schedules the 'update' callback_fn for a given target with a given priority.
The 'update' callback_fn will be called every frame.
The lower the priority, the earlier it is called.
//register this object to scheduler cc.Director.getInstance().getScheduler().scheduleUpdateForTarget(this, priority, !this._isRunning );
- Parameters:
- {cc.Class} target
- {Number} priority
- {Boolean} paused
Modifies the time of all scheduled callbacks.
You can use this property to create a 'slow motion' or 'fast forward' effect.
Default is 1.0. To create a 'slow motion' effect, use values below 1.0.
To create a 'fast forward' effect, use values higher than 1.0.
- Parameters:
- {Number} timeScale
Unschedules all function callbacks from all targets.
You should NEVER call this method, unless you know what you are doing.
- Parameters:
- {cc.Class} target
Unschedules all function callbacks from all targets with a minimum priority.
You should only call this with kCCPriorityNonSystemMin or higher.
- Parameters:
- {Number} minPriority
Unschedule a callback function for a given target.
If you want to unschedule the "update", use unscheudleUpdateForTarget.
//unschedule a selector of target cc.Director.getInstance().getScheduler().unscheduleCallbackForTarget(function, this);
- Parameters:
- {cc.Class} target
- {function} callback_fn
//unschedules the "update" method. cc.Director.getInstance().getScheduler().unscheduleUpdateForTarget(this);
- Parameters:
- {cc.Class} target
- Parameters:
- {Number} dt
- delta time