CCScheduler Class Reference
| Inherits from | NSObject |
| Declared in | CCScheduler.h |
Overview
CCScheduler 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’.
Tasks
Other Methods
-
timeScaleModifies 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.
property -
– update:‘update’ the scheduler. You should NEVER call this method, unless you know what you are doing.
-
– scheduleSelector:forTarget:interval:repeat:delay: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
-
– scheduleSelector:forTarget:interval:paused:calls scheduleSelector with kCCRepeatForever and a 0 delay
-
– scheduleUpdateForTarget:priority:paused: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.
-
– scheduleBlockForKey:target:interval:repeat:delay:paused:block:The scheduled block will be called every ‘interval’ seconds. ‘key’ is a unique identifier of the block. Needed to unschedule the block or update its interval. ‘target’ is needed for all the method related to “target” like “pause” and “unschedule” If ‘interval’ is 0, it will be called every frame, but if so, it recommended to use ‘scheduleUpdateForTarget:’ instead. ‘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. If paused is YES, then it won’t be called until it is resumed. If the block is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
-
– unscheduleSelector:forTarget:Unshedules a selector for a given target. If you want to unschedule the “update”, use unscheudleUpdateForTarget.
-
– unscheduleBlockForKey:target:Unshedules a block for a given key / target pair. If you want to unschedule the “update”, use unscheudleUpdateForTarget.
-
– unscheduleUpdateForTarget:Unschedules the update selector for a given target
-
– unscheduleAllForTarget:Unschedules all selectors and blocks for a given target. This also includes the “update” selector.
-
– unscheduleAllUnschedules all selectors and blocks from all targets. You should NEVER call this method, unless you know what you are doing.
-
– unscheduleAllWithMinPriority:Unschedules all selectors and blocks from all targets with a minimum priority. You should only call this with kCCPriorityNonSystemMin or higher.
-
– 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
-
– pauseAllTargetsPause all selectors and blocks from all targets. You should NEVER call this method, unless you know what you are doing.
-
– pauseAllTargetsWithMinPriority:Pause all selectors and blocks 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 pauseAllSelectors.
Other Methods
-
+ sharedSchedulerreturns a shared instance of the Scheduler
-
+ purgeSharedSchedulerpurges the shared scheduler. It releases the retained instance.
-
– tick:‘tick’ the scheduler. You should NEVER call this method, unless you know what you are doing.
-
– unscheduleAllSelectorsForTarget:Unschedules all selectors for a given target. This also includes the “update” selector.
-
– unscheduleAllSelectorsUnschedules all selectors from all targets. You should NEVER call this method, unless you know what you are doing.
-
– scheduleTimer:schedules a Timer. It will be fired in every frame. (Deprecated: Use scheduleSelector:forTarget:interval:paused instead. Will be removed in 1.0)
-
– unscheduleTimer:unschedules an already scheduled Timer (Deprecated: Use unscheduleSelector:forTarget. Will be removed in v1.0)
-
– unscheduleAllTimersunschedule all timers. You should NEVER call this method, unless you know what you are doing. (Deprecated: Use scheduleAllSelectors instead. Will be removed in 1.0)
KoboldExtensions Methods
Deprecated Methods
Properties
timeScale
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.
@property (nonatomic, readwrite) ccTime timeScaleAvailability
Discussion
Warning: It will affect EVERY scheduled selector / action.
Declared In
CCScheduler.hClass Methods
Instance Methods
isTargetPaused:
Returns whether or not the target is paused
- (BOOL)isTargetPaused:(id)targetAvailability
Declared In
CCScheduler.hpauseAllTargets
Pause all selectors and blocks from all targets. You should NEVER call this method, unless you know what you are doing.
- (NSSet *)pauseAllTargetsAvailability
Declared In
CCScheduler.hpauseAllTargetsWithMinPriority:
Pause all selectors and blocks from all targets with a minimum priority. You should only call this with kCCPriorityNonSystemMin or higher.
- (NSSet *)pauseAllTargetsWithMinPriority:(NSInteger)minPriorityAvailability
Declared In
CCScheduler.hpauseTarget:
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.
- (void)pauseTarget:(id)targetAvailability
Declared In
CCScheduler.hresumeTarget:
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.
- (void)resumeTarget:(id)targetAvailability
Declared In
CCScheduler.hresumeTargets:
Resume selectors on a set of targets. This can be useful for undoing a call to pauseAllSelectors.
- (void)resumeTargets:(NSSet *)targetsToResumeAvailability
Declared In
CCScheduler.hscheduleBlockForKey:target:interval:repeat:delay:paused:block:
The scheduled block will be called every ‘interval’ seconds. ‘key’ is a unique identifier of the block. Needed to unschedule the block or update its interval. ‘target’ is needed for all the method related to “target” like “pause” and “unschedule” If ‘interval’ is 0, it will be called every frame, but if so, it recommended to use ‘scheduleUpdateForTarget:’ instead. ‘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. If paused is YES, then it won’t be called until it is resumed. If the block is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
- (void)scheduleBlockForKey:(NSString *)key target:(id)target interval:(ccTime)interval repeat:(uint)repeat delay:(ccTime)delay paused:(BOOL)paused block:(void ( ^ ) ( ccTime dt ))blockAvailability
Declared In
CCScheduler.hscheduleSelector:forTarget:interval:paused:
calls scheduleSelector with kCCRepeatForever and a 0 delay
- (void)scheduleSelector:(SEL)selector forTarget:(id)target interval:(ccTime)interval paused:(BOOL)pausedDeclared In
CCScheduler.hscheduleSelector:forTarget:interval:repeat:delay: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
- (void)scheduleSelector:(SEL)selector forTarget:(id)target interval:(ccTime)interval repeat:(uint)repeat delay:(ccTime)delay paused:(BOOL)pausedAvailability
Declared In
CCScheduler.hscheduleTimer:
schedules a Timer. It will be fired in every frame. (Deprecated: Use scheduleSelector:forTarget:interval:paused instead. Will be removed in 1.0)
- (void)scheduleTimer:(CCTimer *)timerDeclared In
CCScheduler.hscheduleUpdateForTarget:priority:paused:
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.
- (void)scheduleUpdateForTarget:(id)target priority:(NSInteger)priority paused:(BOOL)pausedAvailability
Declared In
CCScheduler.htick:
‘tick’ the scheduler. You should NEVER call this method, unless you know what you are doing.
- (void)tick:(ccTime)dtDeclared In
CCScheduler.hunscheduleAll
Unschedules all selectors and blocks from all targets. You should NEVER call this method, unless you know what you are doing.
- (void)unscheduleAllAvailability
Declared In
CCScheduler.hunscheduleAllForTarget:
Unschedules all selectors and blocks for a given target. This also includes the “update” selector.
- (void)unscheduleAllForTarget:(id)targetAvailability
Declared In
CCScheduler.hunscheduleAllSelectors
Unschedules all selectors from all targets. You should NEVER call this method, unless you know what you are doing.
- (void)unscheduleAllSelectorsAvailability
Declared In
CCScheduler.hunscheduleAllSelectorsForTarget:
Unschedules all selectors for a given target. This also includes the “update” selector.
- (void)unscheduleAllSelectorsForTarget:(id)targetAvailability
Declared In
CCScheduler.hunscheduleAllTimers
unschedule all timers. You should NEVER call this method, unless you know what you are doing. (Deprecated: Use scheduleAllSelectors instead. Will be removed in 1.0)
- (void)unscheduleAllTimersAvailability
Declared In
CCScheduler.hunscheduleAllWithMinPriority:
Unschedules all selectors and blocks from all targets with a minimum priority. You should only call this with kCCPriorityNonSystemMin or higher.
- (void)unscheduleAllWithMinPriority:(NSInteger)minPriorityAvailability
Declared In
CCScheduler.hunscheduleBlockForKey:target:
Unshedules a block for a given key / target pair. If you want to unschedule the “update”, use unscheudleUpdateForTarget.
- (void)unscheduleBlockForKey:(NSString *)key target:(id)targetAvailability
Declared In
CCScheduler.hunscheduleSelector:forTarget:
Unshedules a selector for a given target. If you want to unschedule the “update”, use unscheudleUpdateForTarget.
- (void)unscheduleSelector:(SEL)selector forTarget:(id)targetAvailability
Declared In
CCScheduler.hunscheduleTimer:
unschedules an already scheduled Timer (Deprecated: Use unscheduleSelector:forTarget. Will be removed in v1.0)
- (void)unscheduleTimer:(CCTimer *)timerDeclared In
CCScheduler.h