-
Notifications
You must be signed in to change notification settings - Fork 421
CAScheduler
CrossApp’s task scheduling, it’s the commonly referred timer.
CAObject
Access modifier |
Attribute name |
Description |
Public |
Target |
Timer subordinated object |
Access modifier |
Attribute name |
Description |
Public |
schedule |
Start timer |
Public |
schedule |
Method reloading, start timer |
Public |
unschedule |
Remove timer |
Public |
unscheduleAllForTarget |
Remove all timers of appointed object |
Public |
unscheduleAll |
Remove all timers of current timer |
Public |
isScheduled |
Appointed object’s timer exist or not |
Public |
getScheduler |
Obtain a CAScheduler singleton |
Public |
pauseTarget |
Pause timer of appointed object |
Public |
resumeTarget |
Recover timer of appointed object |
Public |
isTargetPaused |
Appointed object’s timer is paused or not |
Public |
resumeTargets |
Recover all timers of object collection |
Target
Type: CAObject*
Description: timer scheduler, every timer needs a CAObject* to start.
static void schedule(SEL_SCHEDULE pfnSelector, CAObject *pTarget, float fInterval,unsigned int repeat, float delay, bool bPaused)
Return value: void
Parameter:
Type |
Parameter |
Description |
SEL_SCHEDULE |
pfnSelector |
Call-back function of timer |
CAObject* |
pTarget |
Timer subordinated object |
Float |
fInterval |
Schedule timer’s time interval |
unsigned int |
Repeat |
Schedule times except for the first time |
float |
Delay |
Deferred time before first time schedule |
Bool |
bPaused |
Time is in pause status or not |
Example:
1 2 3 4 5 6 7 8 9 10 11 |
progress = CAProgress::create(); progress->setFrame(CCRect(winRect.size.width*0.5-100,winRect.size.height*0.5+100,200,16)); progress->setProgresstrackColor(ccYELLOW); this->getView()->addSubview(progress);
CAScheduler::schedule(schedule_selector(FifthViewController::changeValue),this,1,3,4,false); void FifthViewController::changeValue(float interval) { float currentValue = progress->getProgress(); progress->setProgress(currentValue+0.1); } |
Set a timer with one second schedule time interval and four second schedule deferred. Schedule repetitive three times except for the first time schedule and progress bar’s value adds 10% for every schedule, so the value is 40% after four times schedule.
static void schedule(SEL_SCHEDULE pfnSelector, CAObject *pTarget, float fInterval, bool bPaused)
Return value: void
Parameter:
Type |
Parameter name |
Description |
SEL_SCHEDULE |
pfnSelector |
Timer call-back function |
CAObject* |
pTarget |
Timer subordinated object |
float |
fInterval |
Schedule timer’s time interval |
bool |
bPaused |
Timer is in pause status or not |
Example:
1 |
CAScheduler::schedule(schedule_selector(FifthViewController::changeValue),this,1,false); |
Set a timer with one second schedule time interval and progress bar’s value will add 10% every one second.
static void unschedule(SEL_SCHEDULE pfnSelector, CAObject *pTarget)
Return value: void
Parameter:
Type |
Parameter name |
Description |
SEL_SCHEDULE |
pfnSelector |
Timer call-back function |
CAObject* |
pTarget |
Timer subordinated object |
static void unscheduleAllForTarget(CAObject *pTarget)
Return value: void
Parameter:
Type |
Parameter name |
Description |
SEL_SCHEDULE |
pfnSelector |
Timer call-back function |
CAObject* |
pTarget |
Timer subordinated object |
static void unscheduleAll(void)
Return value: void
static bool isScheduled(SEL_SCHEDULE pfnSelector, CAObject *pTarget)
Return value: bool
Parameter:
Type |
Parameter name |
Description |
SEL_SCHEDULE |
pfnSelector |
Timer call-back function |
CAObject* |
pTarget |
Timer subordinated object |
static CAScheduler getScheduler()*
Description: return a CAScheduler singleton object
void pauseTarget(CAObject *pTarget)
Return value: void
Parameter:
Type |
Parameter name |
Description |
CAObject* |
pTarget |
Timer subordinated object |
Example:
1 |
CAScheduler::getScheduler()->pauseTarget(this); |
void resumeTarget(CAObject *pTarget)
Return value: void
Parameter:
Type |
Parameter name |
Description |
CAObject* |
pTarget |
Timer subordinated object |
Example:
1 |
CAScheduler::getScheduler()->pauseTarget(this); |
bool isTargetPaused(CAObject *pTarget)
Return value: bool
Parameter:
Type |
Parameter name |
Description |
CAObject* |
pTarget |
Timer subordinated object |
Example:
1 2 |
bool isPaused=CAScheduler::getScheduler()->isTargetPaused(this) ; |
Returning a bool value and judge all timers of current object are paused or not.
void resumeTargets(CCSet targetsToResume)*
Return value: void
Parameter:
Type |
Parameter |
Description |
CCSet* |
targetsToResume |
Timer object collection |