Cocos2d-x  v3.17
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
Scheduler Class Reference

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

Inherits Ref.

Public Member Functions

virtual ~Scheduler ()
 Destructor. More...
 
float getTimeScale ()
 Gets the time scale of schedule callbacks. More...
 
var getTimeScale ()
 Gets the time scale of schedule callbacks. More...
 
local getTimeScale ()
 Gets the time scale of schedule callbacks. More...
 
void setTimeScale (float timeScale)
 Modifies the time of all scheduled callbacks. More...
 
local setTimeScale ( local timeScale)
 Modifies the time of all scheduled callbacks. More...
 
void update (float dt)
 'update' the scheduler. More...
 
void schedule (const ccSchedulerFunc &callback, void *target, float interval, unsigned int repeat, float delay, bool paused, const std::string &key)
 The scheduled method will be called every 'interval' seconds. More...
 
local schedule ( local callback, local target, local interval, local repeat, local delay, local paused, local key)
 The scheduled method will be called every 'interval' seconds. More...
 
void schedule (const ccSchedulerFunc &callback, void *target, float interval, bool paused, const std::string &key)
 The scheduled method will be called every 'interval' seconds for ever. More...
 
void schedule (SEL_SCHEDULE selector, Ref *target, float interval, unsigned int repeat, float delay, bool paused)
 The scheduled method will be called every interval seconds. More...
 
local schedule ( local selector, local target, local interval, local repeat, local delay, local paused)
 The scheduled method will be called every interval seconds. More...
 
void schedule (SEL_SCHEDULE selector, Ref *target, float interval, bool paused)
 The scheduled method will be called every interval seconds for ever. More...
 
template<class T >
void scheduleUpdate (T *target, int priority, bool paused)
 Schedules the 'update' selector for a given target with a given priority. More...
 
unsigned int scheduleScriptFunc (unsigned int handler, float interval, bool paused)
 The scheduled script callback will be called every 'interval' seconds. More...
 
void unschedule (const std::string &key, void *target)
 Unschedules a callback for a key and a given target. More...
 
void unschedule (SEL_SCHEDULE selector, Ref *target)
 Unschedules a selector for a given target. More...
 
var unschedule ( var selector, var target)
 Unschedules a selector for a given target. More...
 
local unschedule ( local selector, local target)
 Unschedules a selector for a given target. More...
 
void unscheduleUpdate (void *target)
 Unschedules the update selector for a given target. More...
 
var unscheduleUpdate ( var target)
 Unschedules the update selector for a given target. More...
 
local unscheduleUpdate ( local target)
 Unschedules the update selector for a given target. More...
 
void unscheduleAllForTarget (void *target)
 Unschedules all selectors for a given target. More...
 
void unscheduleAll ()
 Unschedules all selectors from all targets. More...
 
void unscheduleAllWithMinPriority (int minPriority)
 Unschedules all selectors from all targets with a minimum priority. More...
 
void unscheduleScriptEntry (unsigned int scheduleScriptEntryID)
 Unschedule a script entry. More...
 
bool isScheduled (const std::string &key, const void *target) const
 Checks whether a callback associated with 'key' and 'target' is scheduled. More...
 
bool isScheduled (SEL_SCHEDULE selector, const Ref *target) const
 Checks whether a selector for a given target is scheduled. More...
 
var isScheduled ( var selector, var target)
 Checks whether a selector for a given target is scheduled. More...
 
local isScheduled ( local selector, local target)
 Checks whether a selector for a given target is scheduled. More...
 
void pauseTarget (void *target)
 Pauses the target. More...
 
void resumeTarget (void *target)
 Resumes the target. More...
 
var resumeTarget ( var target)
 Resumes the target. More...
 
local resumeTarget ( local target)
 Resumes the target. More...
 
bool isTargetPaused (void *target)
 Returns whether or not the target is paused. More...
 
std::set< void * > pauseAllTargets ()
 Pause all selectors from all targets. More...
 
var pauseAllTargets ()
 Pause all selectors from all targets. More...
 
local pauseAllTargets ()
 Pause all selectors from all targets. More...
 
std::set< void * > pauseAllTargetsWithMinPriority (int minPriority)
 Pause all selectors from all targets with a minimum priority. More...
 
local pauseAllTargetsWithMinPriority ( local minPriority)
 Pause all selectors from all targets with a minimum priority. More...
 
void resumeTargets (const std::set< void * > &targetsToResume)
 Resume selectors on a set of targets. More...
 
void performFunctionInCocosThread (std::function< void()> function)
 Calls a function on the cocos2d thread. More...
 
void removeAllFunctionsToBePerformedInCocosThread ()
 Remove all pending functions queued to be performed with Scheduler::performFunctionInCocosThread Functions unscheduled in this manner will not be executed This function is thread safe. More...
 
void scheduleSelector (SEL_SCHEDULE selector, Ref *target, float interval, unsigned int repeat, float delay, bool paused)
 The scheduled method will be called every 'interval' seconds. More...
 
local scheduleSelector ( local selector, local target, local interval, local repeat, local delay, local paused)
 The scheduled method will be called every 'interval' seconds. More...
 
void scheduleSelector (SEL_SCHEDULE selector, Ref *target, float interval, bool paused)
 Calls scheduleSelector with CC_REPEAT_FOREVER and a 0 delay. More...
 
template<class T >
void scheduleUpdateForTarget (T *target, int priority, bool paused)
 Schedules the 'update' selector for a given target with a given priority. More...
 
void unscheduleSelector (SEL_SCHEDULE selector, Ref *target)
 Unschedule a selector for a given target. More...
 
bool isScheduledForTarget (Ref *target, SEL_SCHEDULE selector)
 Checks whether a selector for a given target is scheduled. More...
 
void unscheduleUpdateForTarget (Ref *target)
 Unschedules the update selector for a given target. More...
 
var unscheduleUpdateForTarget ( var target)
 Unschedules the update selector for a given target. More...
 
local unscheduleUpdateForTarget ( local target)
 Unschedules the update selector for a given target. More...
 
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
local release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
local getReferenceCount ()
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()
 Destructor. More...
 

Static Public Attributes

static const int PRIORITY_SYSTEM
 Priority level reserved for system services.
 
var PRIORITY_SYSTEM
 Priority level reserved for system services.
 
local PRIORITY_SYSTEM
 Priority level reserved for system services.
 

Additional Inherited Members

- Public Attributes inherited from Ref
unsigned int _ID
 object id, ScriptSupport need public _ID
 
local _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 
local _luaID
 Lua reference id.
 
void * _scriptObject
 scriptObject, support for swift
 
local _scriptObject
 scriptObject, support for swift
 
bool _rooted
 When true, it means that the object was already rooted.
 
local _rooted
 When true, it means that the object was already rooted.
 

Detailed Description

Scheduler is responsible for triggering the scheduled callbacks.

You should not use system timer for your game logic. 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

virtual ~Scheduler ( )
virtual

Destructor.

Member Function Documentation

float getTimeScale ( )
inline

Gets the time scale of schedule callbacks.

See also
Scheduler::setTimeScale()
var getTimeScale ( )
inline

Gets the time scale of schedule callbacks.

See also
Scheduler::setTimeScale()
local getTimeScale ( )
inline

Gets the time scale of schedule callbacks.

See also
Scheduler::setTimeScale()
void setTimeScale ( float  timeScale)
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.
var setTimeScale ( var  timeScale)
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.
local setTimeScale ( local  timeScale)
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 update ( float  dt)

'update' the scheduler.

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

var update ( var  dt)

'update' the scheduler.

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

void schedule ( const ccSchedulerFunc &  callback,
void *  target,
float  interval,
unsigned int  repeat,
float  delay,
bool  paused,
const std::string &  key 
)

The scheduled method will be called every 'interval' seconds.

If paused is true, 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 'scheduleUpdate' instead. If the 'callback' 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.

Parameters
callbackThe callback function.
targetThe target of the callback function.
intervalThe interval to schedule the callback. If the value is 0, then the callback will be scheduled every frame.
repeatrepeat+1 times to schedule the callback.
delaySchedule call back after delay seconds. If the value is not 0, the first schedule will happen after delay seconds. But it will only affect first schedule. After first schedule, the delay time is determined by interval.
pausedWhether or not to pause the schedule.
keyThe key to identify the callback function, because there is not way to identify a std::function<>.
Since
v3.0
var schedule ( var  callback,
var  target,
var  interval,
var  repeat,
var  delay,
var  paused,
var  key 
)

The scheduled method will be called every 'interval' seconds.

If paused is true, 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 'scheduleUpdate' instead. If the 'callback' 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.

Parameters
callbackThe callback function.
targetThe target of the callback function.
intervalThe interval to schedule the callback. If the value is 0, then the callback will be scheduled every frame.
repeatrepeat+1 times to schedule the callback.
delaySchedule call back after delay seconds. If the value is not 0, the first schedule will happen after delay seconds. But it will only affect first schedule. After first schedule, the delay time is determined by interval.
pausedWhether or not to pause the schedule.
keyThe key to identify the callback function, because there is not way to identify a std::function<>.
Since
v3.0
local schedule ( local  callback,
local  target,
local  interval,
local  repeat,
local  delay,
local  paused,
local  key 
)

The scheduled method will be called every 'interval' seconds.

If paused is true, 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 'scheduleUpdate' instead. If the 'callback' 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.

Parameters
callbackThe callback function.
targetThe target of the callback function.
intervalThe interval to schedule the callback. If the value is 0, then the callback will be scheduled every frame.
repeatrepeat+1 times to schedule the callback.
delaySchedule call back after delay seconds. If the value is not 0, the first schedule will happen after delay seconds. But it will only affect first schedule. After first schedule, the delay time is determined by interval.
pausedWhether or not to pause the schedule.
keyThe key to identify the callback function, because there is not way to identify a std::function<>.
Since
v3.0
void schedule ( const ccSchedulerFunc &  callback,
void *  target,
float  interval,
bool  paused,
const std::string &  key 
)

The scheduled method will be called every 'interval' seconds for ever.

Parameters
callbackThe callback function.
targetThe target of the callback function.
intervalThe interval to schedule the callback. If the value is 0, then the callback will be scheduled every frame.
pausedWhether or not to pause the schedule.
keyThe key to identify the callback function, because there is not way to identify a std::function<>.
Since
v3.0
var schedule ( var  callback,
var  target,
var  interval,
var  paused,
var  key 
)

The scheduled method will be called every 'interval' seconds for ever.

Parameters
callbackThe callback function.
targetThe target of the callback function.
intervalThe interval to schedule the callback. If the value is 0, then the callback will be scheduled every frame.
pausedWhether or not to pause the schedule.
keyThe key to identify the callback function, because there is not way to identify a std::function<>.
Since
v3.0
local schedule ( local  callback,
local  target,
local  interval,
local  paused,
local  key 
)

The scheduled method will be called every 'interval' seconds for ever.

Parameters
callbackThe callback function.
targetThe target of the callback function.
intervalThe interval to schedule the callback. If the value is 0, then the callback will be scheduled every frame.
pausedWhether or not to pause the schedule.
keyThe key to identify the callback function, because there is not way to identify a std::function<>.
Since
v3.0
void schedule ( SEL_SCHEDULE  selector,
Ref target,
float  interval,
unsigned int  repeat,
float  delay,
bool  paused 
)

The scheduled method will be called every interval seconds.

If paused is true, 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 'scheduleUpdate' 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 CC_REPEAT_FOREVER to let the action run continuously delay is the amount of time the action will wait before it'll start

Parameters
selectorThe callback function.
targetThe target of the callback function.
intervalThe interval to schedule the callback. If the value is 0, then the callback will be scheduled every frame.
repeatrepeat+1 times to schedule the callback.
delaySchedule call back after delay seconds. If the value is not 0, the first schedule will happen after delay seconds. But it will only affect first schedule. After first schedule, the delay time is determined by interval.
pausedWhether or not to pause the schedule.
Since
v3.0
var schedule ( var  selector,
var  target,
var  interval,
var  repeat,
var  delay,
var  paused 
)

The scheduled method will be called every interval seconds.

If paused is true, 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 'scheduleUpdate' 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 CC_REPEAT_FOREVER to let the action run continuously delay is the amount of time the action will wait before it'll start

Parameters
selectorThe callback function.
targetThe target of the callback function.
intervalThe interval to schedule the callback. If the value is 0, then the callback will be scheduled every frame.
repeatrepeat+1 times to schedule the callback.
delaySchedule call back after delay seconds. If the value is not 0, the first schedule will happen after delay seconds. But it will only affect first schedule. After first schedule, the delay time is determined by interval.
pausedWhether or not to pause the schedule.
Since
v3.0
local schedule ( local  selector,
local  target,
local  interval,
local  repeat,
local  delay,
local  paused 
)

The scheduled method will be called every interval seconds.

If paused is true, 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 'scheduleUpdate' 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 CC_REPEAT_FOREVER to let the action run continuously delay is the amount of time the action will wait before it'll start

Parameters
selectorThe callback function.
targetThe target of the callback function.
intervalThe interval to schedule the callback. If the value is 0, then the callback will be scheduled every frame.
repeatrepeat+1 times to schedule the callback.
delaySchedule call back after delay seconds. If the value is not 0, the first schedule will happen after delay seconds. But it will only affect first schedule. After first schedule, the delay time is determined by interval.
pausedWhether or not to pause the schedule.
Since
v3.0
void schedule ( SEL_SCHEDULE  selector,
Ref target,
float  interval,
bool  paused 
)

The scheduled method will be called every interval seconds for ever.

Parameters
selectorThe callback function.
targetThe target of the callback function.
intervalThe interval to schedule the callback. If the value is 0, then the callback will be scheduled every frame.
pausedWhether or not to pause the schedule.
var schedule ( var  selector,
var  target,
var  interval,
var  paused 
)

The scheduled method will be called every interval seconds for ever.

Parameters
selectorThe callback function.
targetThe target of the callback function.
intervalThe interval to schedule the callback. If the value is 0, then the callback will be scheduled every frame.
pausedWhether or not to pause the schedule.
local schedule ( local  selector,
local  target,
local  interval,
local  paused 
)

The scheduled method will be called every interval seconds for ever.

Parameters
selectorThe callback function.
targetThe target of the callback function.
intervalThe interval to schedule the callback. If the value is 0, then the callback will be scheduled every frame.
pausedWhether or not to pause the schedule.
void scheduleUpdate ( T *  target,
int  priority,
bool  paused 
)
inline

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
v3.0
var scheduleUpdate ( var  target,
var  priority,
var  paused 
)
inline

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
v3.0
unsigned int scheduleScriptFunc ( unsigned int  handler,
float  interval,
bool  paused 
)

The scheduled script callback will be called every 'interval' seconds.

If paused is true, 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().

Don't invoke this function unless you know what you are doing.

void unschedule ( const std::string &  key,
void *  target 
)

Unschedules a callback for a key and a given target.

If you want to unschedule the 'callbackPerFrame', use unscheduleUpdate.

Parameters
keyThe key to identify the callback function, because there is not way to identify a std::function<>.
targetThe target to be unscheduled.
Since
v3.0
var unschedule ( var  key,
var  target 
)

Unschedules a callback for a key and a given target.

If you want to unschedule the 'callbackPerFrame', use unscheduleUpdate.

Parameters
keyThe key to identify the callback function, because there is not way to identify a std::function<>.
targetThe target to be unscheduled.
Since
v3.0
local unschedule ( local  key,
local  target 
)

Unschedules a callback for a key and a given target.

If you want to unschedule the 'callbackPerFrame', use unscheduleUpdate.

Parameters
keyThe key to identify the callback function, because there is not way to identify a std::function<>.
targetThe target to be unscheduled.
Since
v3.0
void unschedule ( SEL_SCHEDULE  selector,
Ref target 
)

Unschedules a selector for a given target.

If you want to unschedule the "update", use unscheduleUpdate().

Parameters
selectorThe selector that is unscheduled.
targetThe target of the unscheduled selector.
Since
v3.0
var unschedule ( var  selector,
var  target 
)

Unschedules a selector for a given target.

If you want to unschedule the "update", use unscheduleUpdate().

Parameters
selectorThe selector that is unscheduled.
targetThe target of the unscheduled selector.
Since
v3.0
local unschedule ( local  selector,
local  target 
)

Unschedules a selector for a given target.

If you want to unschedule the "update", use unscheduleUpdate().

Parameters
selectorThe selector that is unscheduled.
targetThe target of the unscheduled selector.
Since
v3.0
void unscheduleUpdate ( void *  target)

Unschedules the update selector for a given target.

Parameters
targetThe target to be unscheduled.
Since
v0.99.3
var unscheduleUpdate ( var  target)

Unschedules the update selector for a given target.

Parameters
targetThe target to be unscheduled.
Since
v0.99.3
local unscheduleUpdate ( local  target)

Unschedules the update selector for a given target.

Parameters
targetThe target to be unscheduled.
Since
v0.99.3
void unscheduleAllForTarget ( void *  target)

Unschedules all selectors for a given target.

This also includes the "update" selector.

Parameters
targetThe target to be unscheduled.
Since
v0.99.3
var unscheduleAllForTarget ( var  target)

Unschedules all selectors for a given target.

This also includes the "update" selector.

Parameters
targetThe target to be unscheduled.
Since
v0.99.3
void unscheduleAll ( )

Unschedules all selectors from all targets.

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

Since
v0.99.3
var unscheduleAll ( )

Unschedules all selectors from all targets.

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

Since
v0.99.3
local unscheduleAll ( )

Unschedules all selectors from all targets.

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

Since
v0.99.3
void unscheduleAllWithMinPriority ( int  minPriority)

Unschedules all selectors from all targets with a minimum priority.

You should only call this with PRIORITY_NON_SYSTEM_MIN or higher.

Parameters
minPriorityThe minimum priority of selector to be unscheduled. Which means, all selectors which priority is higher than minPriority will be unscheduled.
Since
v2.0.0
var unscheduleAllWithMinPriority ( var  minPriority)

Unschedules all selectors from all targets with a minimum priority.

You should only call this with PRIORITY_NON_SYSTEM_MIN or higher.

Parameters
minPriorityThe minimum priority of selector to be unscheduled. Which means, all selectors which priority is higher than minPriority will be unscheduled.
Since
v2.0.0
local unscheduleAllWithMinPriority ( local  minPriority)

Unschedules all selectors from all targets with a minimum priority.

You should only call this with PRIORITY_NON_SYSTEM_MIN or higher.

Parameters
minPriorityThe minimum priority of selector to be unscheduled. Which means, all selectors which priority is higher than minPriority will be unscheduled.
Since
v2.0.0
void unscheduleScriptEntry ( unsigned int  scheduleScriptEntryID)

Unschedule a script entry.

Warning
Don't invoke this function unless you know what you are doing.
bool isScheduled ( const std::string &  key,
const void *  target 
) const

Checks whether a callback associated with 'key' and 'target' is scheduled.

Parameters
keyThe key to identify the callback function, because there is not way to identify a std::function<>.
targetThe target of the callback.
Returns
True if the specified callback is invoked, false if not.
Since
v3.0.0
var isScheduled ( var  key,
var  target 
)

Checks whether a callback associated with 'key' and 'target' is scheduled.

Parameters
keyThe key to identify the callback function, because there is not way to identify a std::function<>.
targetThe target of the callback.
Returns
True if the specified callback is invoked, false if not.
Since
v3.0.0
local isScheduled ( local  key,
local  target 
)

Checks whether a callback associated with 'key' and 'target' is scheduled.

Parameters
keyThe key to identify the callback function, because there is not way to identify a std::function<>.
targetThe target of the callback.
Returns
True if the specified callback is invoked, false if not.
Since
v3.0.0
bool isScheduled ( SEL_SCHEDULE  selector,
const Ref target 
) const

Checks whether a selector for a given target is scheduled.

Parameters
selectorThe selector to be checked.
targetThe target of the callback.
Returns
True if the specified selector is invoked, false if not.
Since
v3.0
var isScheduled ( var  selector,
var  target 
)

Checks whether a selector for a given target is scheduled.

Parameters
selectorThe selector to be checked.
targetThe target of the callback.
Returns
True if the specified selector is invoked, false if not.
Since
v3.0
local isScheduled ( local  selector,
local  target 
)

Checks whether a selector for a given target is scheduled.

Parameters
selectorThe selector to be checked.
targetThe target of the callback.
Returns
True if the specified selector is invoked, false if not.
Since
v3.0
void pauseTarget ( void *  target)

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
targetThe target to be paused.
Since
v0.99.3
var pauseTarget ( var  target)

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
targetThe target to be paused.
Since
v0.99.3
local pauseTarget ( local  target)

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
targetThe target to be paused.
Since
v0.99.3
void resumeTarget ( void *  target)

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.

Parameters
targetThe target to be resumed.
Since
v0.99.3
var resumeTarget ( var  target)

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.

Parameters
targetThe target to be resumed.
Since
v0.99.3
local resumeTarget ( local  target)

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.

Parameters
targetThe target to be resumed.
Since
v0.99.3
bool isTargetPaused ( void *  target)

Returns whether or not the target is paused.

Parameters
targetThe target to be checked.
Returns
True if the target is paused, false if not.
Since
v1.0.0
var isTargetPaused ( var  target)

Returns whether or not the target is paused.

Parameters
targetThe target to be checked.
Returns
True if the target is paused, false if not.
Since
v1.0.0
std::set<void*> pauseAllTargets ( )

Pause all selectors from all targets.

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

Since
v2.0.0
var pauseAllTargets ( )

Pause all selectors from all targets.

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

Since
v2.0.0
local pauseAllTargets ( )

Pause all selectors from all targets.

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

Since
v2.0.0
std::set<void*>
pauseAllTargetsWithMinPriority
( int  minPriority)

Pause all selectors from all targets with a minimum priority.

You should only call this with PRIORITY_NON_SYSTEM_MIN or higher.

Parameters
minPriorityThe minimum priority of selector to be paused. Which means, all selectors which priority is higher than minPriority will be paused.
Since
v2.0.0
var pauseAllTargetsWithMinPriority ( var  minPriority)

Pause all selectors from all targets with a minimum priority.

You should only call this with PRIORITY_NON_SYSTEM_MIN or higher.

Parameters
minPriorityThe minimum priority of selector to be paused. Which means, all selectors which priority is higher than minPriority will be paused.
Since
v2.0.0
local
pauseAllTargetsWithMinPriority
( local  minPriority)

Pause all selectors from all targets with a minimum priority.

You should only call this with PRIORITY_NON_SYSTEM_MIN or higher.

Parameters
minPriorityThe minimum priority of selector to be paused. Which means, all selectors which priority is higher than minPriority will be paused.
Since
v2.0.0
void resumeTargets ( const std::set< void * > &  targetsToResume)

Resume selectors on a set of targets.

This can be useful for undoing a call to pauseAllSelectors.

Parameters
targetsToResumeThe set of targets to be resumed.
Since
v2.0.0
var resumeTargets ( var  targetsToResume)

Resume selectors on a set of targets.

This can be useful for undoing a call to pauseAllSelectors.

Parameters
targetsToResumeThe set of targets to be resumed.
Since
v2.0.0
local resumeTargets ( local  targetsToResume)

Resume selectors on a set of targets.

This can be useful for undoing a call to pauseAllSelectors.

Parameters
targetsToResumeThe set of targets to be resumed.
Since
v2.0.0
void performFunctionInCocosThread ( std::function< void()>  function)

Calls a function on the cocos2d thread.

Useful when you need to call a cocos2d function from another thread. This function is thread safe.

Parameters
functionThe function to be run in cocos2d thread.
Since
v3.0
local performFunctionInCocosThread ( local  function)

Calls a function on the cocos2d thread.

Useful when you need to call a cocos2d function from another thread. This function is thread safe.

Parameters
functionThe function to be run in cocos2d thread.
Since
v3.0
void
removeAllFunctionsToBePerformedInCocosThread
( )

Remove all pending functions queued to be performed with Scheduler::performFunctionInCocosThread Functions unscheduled in this manner will not be executed This function is thread safe.

Since
v3.14
local
removeAllFunctionsToBePerformedInCocosThread
( )

Remove all pending functions queued to be performed with Scheduler::performFunctionInCocosThread Functions unscheduled in this manner will not be executed This function is thread safe.

Since
v3.14
void scheduleSelector ( SEL_SCHEDULE  selector,
Ref target,
float  interval,
unsigned int  repeat,
float  delay,
bool  paused 
)
inline

The scheduled method will be called every 'interval' seconds.

If paused is true, 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 CC_REPEAT_FOREVER to let the action run continuously delay is the amount of time the action will wait before it'll start

local scheduleSelector ( local  selector,
local  target,
local  interval,
local  repeat,
local  delay,
local  paused 
)
inline

The scheduled method will be called every 'interval' seconds.

If paused is true, 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 CC_REPEAT_FOREVER to let the action run continuously delay is the amount of time the action will wait before it'll start

void scheduleSelector ( SEL_SCHEDULE  selector,
Ref target,
float  interval,
bool  paused 
)
inline

Calls scheduleSelector with CC_REPEAT_FOREVER and a 0 delay.

local scheduleSelector ( local  selector,
local  target,
local  interval,
local  paused 
)
inline

Calls scheduleSelector with CC_REPEAT_FOREVER and a 0 delay.

void scheduleUpdateForTarget ( T *  target,
int  priority,
bool  paused 
)
inline

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.

var scheduleUpdateForTarget ( var  target,
var  priority,
var  paused 
)
inline

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.

local scheduleUpdateForTarget ( local  target,
local  priority,
local  paused 
)
inline

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 unscheduleSelector ( SEL_SCHEDULE  selector,
Ref target 
)
inline

Unschedule a selector for a given target.

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

local unscheduleSelector ( local  selector,
local  target 
)
inline

Unschedule a selector for a given target.

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

bool isScheduledForTarget ( Ref target,
SEL_SCHEDULE  selector 
)
inline

Checks whether a selector for a given target is scheduled.

local isScheduledForTarget ( local  target,
local  selector 
)
inline

Checks whether a selector for a given target is scheduled.

void unscheduleUpdateForTarget ( Ref target)
inline

Unschedules the update selector for a given target.

var unscheduleUpdateForTarget ( var  target)
inline

Unschedules the update selector for a given target.

local unscheduleUpdateForTarget ( local  target)
inline

Unschedules the update selector for a given target.


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