cocos2d-x  2.2.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CCScheduler Class Reference

Scheduler is responsible for triggering the scheduled callbacks. More...

#include <CCScheduler.h>

Inheritance diagram for CCScheduler:
CCObject CCCopying

Public Member Functions

 CCScheduler ()
 ~CCScheduler (void)
float getTimeScale (void)
void setTimeScale (float fTimeScale)
 Modifies the time of all scheduled callbacks. More...
 
void update (float dt)
 'update' the scheduler. More...
 
void scheduleSelector (SEL_SCHEDULE pfnSelector, CCObject *pTarget, float fInterval, unsigned int repeat, float delay, bool bPaused)
 The scheduled method will be called every 'interval' seconds. More...
 
void scheduleSelector (SEL_SCHEDULE pfnSelector, CCObject *pTarget, float fInterval, bool bPaused)
 calls scheduleSelector with kCCRepeatForever and a 0 delay More...
 
void scheduleUpdateForTarget (CCObject *pTarget, int nPriority, bool bPaused)
 Schedules the 'update' selector for a given target with a given priority. More...
 
void unscheduleSelector (SEL_SCHEDULE pfnSelector, CCObject *pTarget)
 Unschedule a selector for a given target. More...
 
void unscheduleUpdateForTarget (const CCObject *pTarget)
 Unschedules the update selector for a given target. More...
 
void unscheduleAllForTarget (CCObject *pTarget)
 Unschedules all selectors for a given target. More...
 
void unscheduleAll (void)
 Unschedules all selectors from all targets. More...
 
void unscheduleAllWithMinPriority (int nMinPriority)
 Unschedules all selectors from all targets with a minimum priority. More...
 
unsigned int scheduleScriptFunc (unsigned int nHandler, float fInterval, bool bPaused)
 The scheduled script callback will be called every 'interval' seconds. More...
 
void unscheduleScriptEntry (unsigned int uScheduleScriptEntryID)
 Unschedule a script entry. More...
 
void pauseTarget (CCObject *pTarget)
 Pauses the target. More...
 
void resumeTarget (CCObject *pTarget)
 Resumes the target. More...
 
bool isTargetPaused (CCObject *pTarget)
 Returns whether or not the target is paused. More...
 
CCSetpauseAllTargets ()
 Pause all selectors from all targets. More...
 
CCSetpauseAllTargetsWithMinPriority (int nMinPriority)
 Pause all selectors from all targets with a minimum priority. More...
 
void resumeTargets (CCSet *targetsToResume)
 Resume selectors on a set of targets. More...
 
- Public Member Functions inherited from CCObject
 CCObject (void)
virtual ~CCObject (void)
void release (void)
void retain (void)
CCObjectautorelease (void)
CCObjectcopy (void)
bool isSingleReference (void) const
unsigned int retainCount (void) const
virtual bool isEqual (const CCObject *pObject)
virtual void acceptVisitor (CCDataVisitor &visitor)
- Public Member Functions inherited from CCCopying
virtual CCObjectcopyWithZone (CCZone *pZone)

Protected Attributes

float m_fTimeScale
struct _listEntry * m_pUpdatesNegList
struct _listEntry * m_pUpdates0List
struct _listEntry * m_pUpdatesPosList
struct _hashUpdateEntry * m_pHashForUpdates
struct _hashSelectorEntry * m_pHashForTimers
struct _hashSelectorEntry * m_pCurrentTarget
bool m_bCurrentTargetSalvaged
bool m_bUpdateHashLocked
CCArraym_pScriptHandlerEntries
- Protected Attributes inherited from CCObject
unsigned int m_uReference
unsigned int m_uAutoReleaseCount

Additional Inherited Members

- Public Attributes inherited from CCObject
unsigned int m_uID
int m_nLuaID

Detailed Description

Scheduler is responsible for 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'.

Constructor & Destructor Documentation

~CCScheduler ( void  )

Member Function Documentation

float getTimeScale ( void  )
inline
bool isTargetPaused ( CCObject pTarget)

Returns whether or not the target is paused.

Since
v1.0.0
CCSet* pauseAllTargets ( )

Pause all selectors from all targets.

You should NEVER call this method, unless you know what you are doing.

Since
v2.0.0
CCSet*
pauseAllTargetsWithMinPriority
( int  nMinPriority)

Pause all selectors from all targets with a minimum priority.

You should only call this with kCCPriorityNonSystemMin or higher.

Since
v2.0.0
void pauseTarget ( CCObject pTarget)

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.

Since
v0.99.3
void resumeTarget ( CCObject pTarget)

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.

Since
v0.99.3
void resumeTargets ( CCSet targetsToResume)

Resume selectors on a set of targets.

This can be useful for undoing a call to pauseAllSelectors.

Since
v2.0.0
unsigned int scheduleScriptFunc ( unsigned int  nHandler,
float  fInterval,
bool  bPaused 
)

The scheduled script callback 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. return schedule script entry ID, used for unscheduleScriptFunc().

void scheduleSelector ( SEL_SCHEDULE  pfnSelector,
CCObject pTarget,
float  fInterval,
unsigned int  repeat,
float  delay,
bool  bPaused 
)

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's 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 let 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

Since
v0.99.3, repeat and delay added in v1.1
void scheduleSelector ( SEL_SCHEDULE  pfnSelector,
CCObject pTarget,
float  fInterval,
bool  bPaused 
)

calls scheduleSelector with kCCRepeatForever and a 0 delay

void scheduleUpdateForTarget ( CCObject pTarget,
int  nPriority,
bool  bPaused 
)

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.

Since
v0.99.3
void setTimeScale ( float  fTimeScale)
inline

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.

Since
v0.8
Warning
It will affect EVERY scheduled selector / action.
void unscheduleAll ( void  )

Unschedules all selectors from all targets.

You should NEVER call this method, unless you know what you are doing.

Since
v0.99.3
void unscheduleAllForTarget ( CCObject pTarget)

Unschedules all selectors for a given target.

This also includes the "update" selector.

Since
v0.99.3
void unscheduleAllWithMinPriority ( int  nMinPriority)

Unschedules all selectors from all targets with a minimum priority.

You should only call this with kCCPriorityNonSystemMin or higher.

Since
v2.0.0
void unscheduleScriptEntry ( unsigned int  uScheduleScriptEntryID)

Unschedule a script entry.

void unscheduleSelector ( SEL_SCHEDULE  pfnSelector,
CCObject pTarget 
)

Unschedule a selector for a given target.

If you want to unschedule the "update", use unscheudleUpdateForTarget.

Since
v0.99.3
void unscheduleUpdateForTarget ( const CCObject pTarget)

Unschedules the update selector for a given target.

Since
v0.99.3
void update ( float  dt)
virtual

'update' the scheduler.

You should NEVER call this method, unless you know what you are doing.

Reimplemented from CCObject.

Member Data Documentation

bool m_bCurrentTargetSalvaged
protected
bool m_bUpdateHashLocked
protected
float m_fTimeScale
protected
struct _hashSelectorEntry*
m_pCurrentTarget
protected
struct _hashSelectorEntry*
m_pHashForTimers
protected
struct _hashUpdateEntry*
m_pHashForUpdates
protected
CCArray* m_pScriptHandlerEntries
protected
struct _listEntry* m_pUpdates0List
protected
struct _listEntry*
m_pUpdatesNegList
protected
struct _listEntry*
m_pUpdatesPosList
protected

The documentation for this class was generated from the following file: