diff --git a/cocos2dx/CCDeprecated.cpp b/cocos2dx/CCDeprecated.cpp index 2b0905b3ce..3c225110fc 100644 --- a/cocos2dx/CCDeprecated.cpp +++ b/cocos2dx/CCDeprecated.cpp @@ -153,4 +153,7 @@ const int kCCTransitionOrientationRightOver = TransitionScene::ORIENTATION_RIGHT const int kCCTransitionOrientationUpOver = TransitionScene::ORIENTATION_UP_OVER; const int kCCTransitionOrientationDownOver = TransitionScene::ORIENTATION_DOWN_OVER; +const int kCCPrioritySystem = Scheduler::PRIORITY_SYSTEM; +const int kCCPriorityNonSystemMin = Scheduler::PRIORITY_NON_SYSTEM_MIN; + NS_CC_END \ No newline at end of file diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 52f720a80b..de59b7fb20 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -146,7 +146,7 @@ bool Director::init(void) _scheduler = new Scheduler(); // action manager _actionManager = new ActionManager(); - _scheduler->scheduleUpdateForTarget(_actionManager, kPrioritySystem, false); + _scheduler->scheduleUpdateForTarget(_actionManager, Scheduler::PRIORITY_SYSTEM, false); // touchDispatcher _touchDispatcher = new TouchDispatcher(); _touchDispatcher->init(); diff --git a/cocos2dx/CCScheduler.cpp b/cocos2dx/CCScheduler.cpp index 935a2b4683..fbfcc3b529 100644 --- a/cocos2dx/CCScheduler.cpp +++ b/cocos2dx/CCScheduler.cpp @@ -240,6 +240,12 @@ SEL_SCHEDULE Timer::getSelector() const // implementation of Scheduler +// Priority level reserved for system services. +const int Scheduler::PRIORITY_SYSTEM = INT_MIN; + +// Minimum priority level for user scheduling. +const int Scheduler::PRIORITY_NON_SYSTEM_MIN = PRIORITY_SYSTEM + 1; + Scheduler::Scheduler(void) : _timeScale(1.0f) , _updatesNegList(NULL) @@ -577,7 +583,7 @@ void Scheduler::unscheduleUpdateForTarget(const Object *target) void Scheduler::unscheduleAll(void) { - unscheduleAllWithMinPriority(kPrioritySystem); + unscheduleAllWithMinPriority(PRIORITY_SYSTEM); } void Scheduler::unscheduleAllWithMinPriority(int nMinPriority) @@ -759,7 +765,7 @@ bool Scheduler::isTargetPaused(Object *target) Set* Scheduler::pauseAllTargets() { - return pauseAllTargetsWithMinPriority(kPrioritySystem); + return pauseAllTargetsWithMinPriority(PRIORITY_SYSTEM); } Set* Scheduler::pauseAllTargetsWithMinPriority(int nMinPriority) diff --git a/cocos2dx/CCScheduler.h b/cocos2dx/CCScheduler.h index 4a5d1c9628..3df5cd96ec 100644 --- a/cocos2dx/CCScheduler.h +++ b/cocos2dx/CCScheduler.h @@ -37,12 +37,6 @@ NS_CC_BEGIN * @{ */ -// Priority level reserved for system services. -#define kPrioritySystem INT_MIN - -// Minimum priority level for user scheduling. -#define kPriorityNonSystemMin (kPrioritySystem+1) - class Set; // // Timer @@ -121,6 +115,12 @@ The 'custom selectors' should be avoided when possible. It is faster, and consum class CC_DLL Scheduler : public Object { public: + // Priority level reserved for system services. + static const int PRIORITY_SYSTEM; + + // Minimum priority level for user scheduling. + static const int PRIORITY_NON_SYSTEM_MIN; + Scheduler(); ~Scheduler(void); diff --git a/cocos2dx/include/CCDeprecated.h b/cocos2dx/include/CCDeprecated.h index ee9d15281b..85c4cbcc56 100644 --- a/cocos2dx/include/CCDeprecated.h +++ b/cocos2dx/include/CCDeprecated.h @@ -912,8 +912,8 @@ CC_DEPRECATED_ATTRIBUTE extern const int kCCTransitionOrientationUpOver; CC_DEPRECATED_ATTRIBUTE extern const int kCCTransitionOrientationDownOver; CC_DEPRECATED_ATTRIBUTE typedef enum TransitionScene::Orientation tOrientation; -#define kCCPrioritySystem kPrioritySystem -#define kCCPriorityNonSystemMin kPriorityNonSystemMin +CC_DEPRECATED_ATTRIBUTE extern const int kCCPrioritySystem; +CC_DEPRECATED_ATTRIBUTE extern const int kCCPriorityNonSystemMin; #define kCCTMXTileHorizontalFlag kTMXTileHorizontalFlag #define kCCTMXTileVerticalFlag kTMXTileVerticalFlag diff --git a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp index b4d8cc5de6..94e094198a 100644 --- a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp @@ -359,7 +359,7 @@ void SchedulerPauseResumeAllUser::pause(float dt) { log("Pausing"); Director* director = Director::getInstance(); - _pausedTargets = director->getScheduler()->pauseAllTargetsWithMinPriority(kPriorityNonSystemMin); + _pausedTargets = director->getScheduler()->pauseAllTargetsWithMinPriority(Scheduler::PRIORITY_NON_SYSTEM_MIN); CC_SAFE_RETAIN(_pausedTargets); } @@ -463,7 +463,7 @@ void SchedulerUnscheduleAllHard::onExit() if(!_actionManagerActive) { // Restore the director's action manager. Director* director = Director::getInstance(); - director->getScheduler()->scheduleUpdateForTarget(director->getActionManager(), kPrioritySystem, false); + director->getScheduler()->scheduleUpdateForTarget(director->getActionManager(), Scheduler::PRIORITY_SYSTEM, false); } } @@ -548,7 +548,7 @@ void SchedulerUnscheduleAllUserLevel::tick4(float dt) void SchedulerUnscheduleAllUserLevel::unscheduleAll(float dt) { - Director::getInstance()->getScheduler()->unscheduleAllWithMinPriority(kPriorityNonSystemMin); + Director::getInstance()->getScheduler()->unscheduleAllWithMinPriority(Scheduler::PRIORITY_NON_SYSTEM_MIN); } std::string SchedulerUnscheduleAllUserLevel::title()