Scheduler Class

Module: cc

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 callback: the 'update' callback will be called every frame. You can customize the priority.<br/>
- custom callback: A custom callback will be called every frame, or with a custom interval of time<br/>


The 'custom selectors' should be avoided when possible. It is faster, and consumes less memory to use the 'update callback'. *

Index

Properties
Methods
  • setTimeScale 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.
    Note:It will affect EVERY scheduled selector / action.
  • getTimeScale Returns time scale of scheduler.
  • update 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.)
  • scheduleCallbackForTarget

    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.macro.REPEAT_FOREVER to let the action run continuously
    delay is the amount of time the action will wait before it'll start

  • schedule The schedule
  • scheduleUpdate Schedules the update callback for a given target, the callback will be invoked every frame after schedule started.
  • unschedule Unschedules a callback for a callback and a given target. If you want to unschedule the "update", use unscheduleUpdate()
  • unscheduleUpdate Unschedules the update callback for a given target.
  • unscheduleAllForTarget Unschedules all scheduled callbacks for a given target. This also includes the "update" callback.
  • unscheduleAll Unschedules all scheduled callbacks from all targets including the system callbacks.
    You should NEVER call this method, unless you know what you are doing.
  • unscheduleAllWithMinPriority Unschedules all callbacks from all targets with a minimum priority.
    You should only call this with PRIORITY_NON_SYSTEM_MIN or higher.
  • isScheduled Checks whether a callback for a given target is scheduled.
  • pauseAllTargets Pause all selectors from all targets.
    You should NEVER call this method, unless you know what you are doing.
  • pauseAllTargetsWithMinPriority Pause all selectors from all targets with a minimum priority.
    You should only call this with kCCPriorityNonSystemMin or higher.
  • resumeTargets Resume selectors on a set of targets.
    This can be useful for undoing a call to pauseAllCallbacks.
  • pauseTarget 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.
  • resumeTarget Resumes the target.
    The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.
    If the target is not present, nothing happens.
  • isTargetPaused Returns whether or not the target is paused.
  • scheduleUpdateForTarget 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.
  • unscheduleCallbackForTarget Unschedule a callback function for a given target.
    If you want to unschedule the "update", use unscheduleUpdateForTarget.
  • unscheduleUpdateForTarget Unschedules the update callback function for a given target.
  • unscheduleAllCallbacksForTarget Unschedules all function callbacks for a given target.
    This also includes the "update" callback function.
  • unscheduleAllCallbacks Unschedules all function callbacks from all targets.
    You should NEVER call this method, unless you know what you are doing.
  • unscheduleAllCallbacksWithMinPriority Unschedules all function callbacks from all targets with a minimum priority.
    You should only call this with kCCPriorityNonSystemMin or higher.

Details

Properties

PRIORITY_SYSTEM

Priority level reserved for system services.

meta description
Type Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:1128
PRIORITY_NON_SYSTEM

Minimum priority level for user scheduling.

meta description
Type Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:1137

Methods

setTimeScale

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.
Note:It will affect EVERY scheduled selector / action.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:358
Parameters
getTimeScale

Returns time scale of scheduler.

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:378
update

'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.)

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:388
Parameters
scheduleCallbackForTarget

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.macro.REPEAT_FOREVER to let the action run continuously
delay is the amount of time the action will wait before it'll start

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:478
Deprecated since v3.4 please use .schedule
Parameters
Examples
//register a schedule to scheduler
var scheduler = cc.director.getScheduler();
scheduler.scheduleCallbackForTarget(this, function, interval, repeat, delay, !this._isRunning);
schedule

The schedule

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:516
Parameters
Examples
//register a schedule to scheduler
cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning);
scheduleUpdate

Schedules the update callback for a given target, the callback will be invoked every frame after schedule started.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:580
Parameters
unschedule

Unschedules a callback for a callback and a given target. If you want to unschedule the "update", use unscheduleUpdate()

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:634
Parameters
  • callback Function The callback to be unscheduled
  • target Object The target bound to the callback.
unscheduleUpdate

Unschedules the update callback for a given target.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:683
Parameters
  • target Object The target to be unscheduled.
unscheduleAllForTarget

Unschedules all scheduled callbacks for a given target. This also includes the "update" callback.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:705
Parameters
  • target Object The target to be unscheduled.
unscheduleAll

Unschedules all scheduled callbacks from all targets including the system callbacks.
You should NEVER call this method, unless you know what you are doing.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:745
unscheduleAllWithMinPriority

Unschedules all callbacks from all targets with a minimum priority.
You should only call this with PRIORITY_NON_SYSTEM_MIN or higher.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:758
Parameters
  • minPriority Number The minimum priority of selector to be unscheduled. Which means, all selectors which
     priority is higher than minPriority will be unscheduled.
    
isScheduled

Checks whether a callback for a given target is scheduled.

meta description
Returns Boolean
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:812
Parameters
  • callback Function The callback to check.
  • target Object The target of the callback.
pauseAllTargets

Pause all selectors from all targets.
You should NEVER call this method, unless you know what you are doing.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:850
pauseAllTargetsWithMinPriority

Pause all selectors from all targets with a minimum priority.
You should only call this with kCCPriorityNonSystemMin or higher.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:863
Parameters
resumeTargets

Resume selectors on a set of targets.
This can be useful for undoing a call to pauseAllCallbacks.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:923
Parameters
pauseTarget

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.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:942
Parameters
resumeTarget

Resumes the target.
The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.
If the target is not present, nothing happens.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:973
Parameters
isTargetPaused

Returns whether or not the target is paused.

meta description
Returns Boolean
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:1006
Parameters
scheduleUpdateForTarget

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.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:1030
Deprecated since v3.4 please use .scheduleUpdate
Parameters
Examples
//register this object to scheduler
var scheduler = cc.director.getScheduler();
scheduler.scheduleUpdateForTarget(this, priority, !this._isRunning );
unscheduleCallbackForTarget

Unschedule a callback function for a given target.
If you want to unschedule the "update", use unscheduleUpdateForTarget.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:1051
Deprecated since v3.4 please use .unschedule
Parameters
Examples
//unschedule a callback of target
var scheduler = cc.director.getScheduler();
scheduler.unscheduleCallbackForTarget(this, callback);
unscheduleUpdateForTarget

Unschedules the update callback function for a given target.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:1069
Deprecated since v3.4 please use .unschedule
Parameters
Examples
//unschedules the "update" method.
var scheduler = cc.director.getScheduler();
scheduler.unscheduleUpdateForTarget(this);
unscheduleAllCallbacksForTarget

Unschedules all function callbacks for a given target.
This also includes the "update" callback function.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:1082
Deprecated since v3.4 please use unscheduleAllForTarget
Parameters
unscheduleAllCallbacks

Unschedules all function callbacks from all targets.
You should NEVER call this method, unless you know what you are doing.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:1096
Deprecated since v3.4 please use .unscheduleAllWithMinPriority
unscheduleAllCallbacksWithMinPriority

Unschedules all function callbacks from all targets with a minimum priority.
You should only call this with kCCPriorityNonSystemMin or higher.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCScheduler.js:1111
Deprecated since v3.4 please use .unscheduleAllWithMinPriority
Parameters

results matching ""

    No results matching ""