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

  •   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
  • – 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.

  • – unscheduleAll

    Unschedules 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

  • – pauseAllTargets

    Pause 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

  • + sharedScheduler

    returns a shared instance of the Scheduler

  • + purgeSharedScheduler

    purges 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.

  • – unscheduleAllSelectors

    Unschedules 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)

  • – unscheduleAllTimers

    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)

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 timeScale

Availability

Discussion

Warning: It will affect EVERY scheduled selector / action.

Declared In

CCScheduler.h

Class Methods

purgeSharedScheduler

purges the shared scheduler. It releases the retained instance.

+ (void)purgeSharedScheduler

Availability

Declared In

CCScheduler.h

sharedScheduler

returns a shared instance of the Scheduler

+ (CCScheduler *)sharedScheduler

Declared In

CCScheduler.h

Instance Methods

isTargetPaused:

Returns whether or not the target is paused

- (BOOL)isTargetPaused:(id)target

Availability

Declared In

CCScheduler.h

pauseAllTargets

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

- (NSSet *)pauseAllTargets

Availability

Declared In

CCScheduler.h

pauseAllTargetsWithMinPriority:

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

- (NSSet *)pauseAllTargetsWithMinPriority:(NSInteger)minPriority

Availability

Declared In

CCScheduler.h

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.

- (void)pauseTarget:(id)target

Availability

Declared In

CCScheduler.h

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.

- (void)resumeTarget:(id)target

Availability

Declared In

CCScheduler.h

resumeTargets:

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

- (void)resumeTargets:(NSSet *)targetsToResume

Availability

Declared In

CCScheduler.h

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.

- (void)scheduleBlockForKey:(NSString *)key target:(id)target interval:(ccTime)interval repeat:(uint)repeat delay:(ccTime)delay paused:(BOOL)paused block:(void ( ^ ) ( ccTime dt ))block

Availability

Declared In

CCScheduler.h

scheduleSelector:forTarget:interval:paused:

calls scheduleSelector with kCCRepeatForever and a 0 delay

- (void)scheduleSelector:(SEL)selector forTarget:(id)target interval:(ccTime)interval paused:(BOOL)paused

Declared In

CCScheduler.h

scheduleSelector:forTarget:interval:paused:repeat:delay:

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

- (void)scheduleSelector:(SEL)selector forTarget:(id)target interval:(ccTime)interval repeat:(uint)repeat delay:(ccTime)delay paused:(BOOL)paused

Availability

Declared In

CCScheduler.h

scheduleTimer:

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 *)timer

Declared In

CCScheduler.h

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.

- (void)scheduleUpdateForTarget:(id)target priority:(NSInteger)priority paused:(BOOL)paused

Availability

Declared In

CCScheduler.h

tick:

‘tick’ the scheduler. You should NEVER call this method, unless you know what you are doing.

- (void)tick:(ccTime)dt

Declared In

CCScheduler.h

tickReplacement:

unscheduleAll

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

- (void)unscheduleAll

Availability

Declared In

CCScheduler.h

unscheduleAllForTarget:

Unschedules all selectors and blocks for a given target. This also includes the “update” selector.

- (void)unscheduleAllForTarget:(id)target

Availability

Declared In

CCScheduler.h

unscheduleAllSelectors

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

- (void)unscheduleAllSelectors

Availability

Declared In

CCScheduler.h

unscheduleAllSelectorsForTarget:

Unschedules all selectors for a given target. This also includes the “update” selector.

- (void)unscheduleAllSelectorsForTarget:(id)target

Availability

Declared In

CCScheduler.h

unscheduleAllSelectorsWithMinPriority:

unscheduleAllTimers

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)unscheduleAllTimers

Availability

Declared In

CCScheduler.h

unscheduleAllWithMinPriority:

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

- (void)unscheduleAllWithMinPriority:(NSInteger)minPriority

Availability

Declared In

CCScheduler.h

unscheduleBlockForKey: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)target

Availability

Declared In

CCScheduler.h

unscheduleSelector:forTarget:

Unshedules a selector for a given target. If you want to unschedule the “update”, use unscheudleUpdateForTarget.

- (void)unscheduleSelector:(SEL)selector forTarget:(id)target

Availability

Declared In

CCScheduler.h

unscheduleTimer:

unschedules an already scheduled Timer (Deprecated: Use unscheduleSelector:forTarget. Will be removed in v1.0)

- (void)unscheduleTimer:(CCTimer *)timer

Declared In

CCScheduler.h

unscheduleUpdateForTarget:

Unschedules the update selector for a given target

- (void)unscheduleUpdateForTarget:(id)target

Availability

Declared In

CCScheduler.h

update:

‘update’ the scheduler. You should NEVER call this method, unless you know what you are doing.

- (void)update:(ccTime)dt

Declared In

CCScheduler.h