void SchedulerPauseResumeAllUser::resume(float dt) { CCLog("Resuming"); CCDirector* pDirector = CCDirector::sharedDirector(); pDirector->getScheduler()->resumeTargets(m_pPausedTargets); CC_SAFE_RELEASE_NULL(m_pPausedTargets); }
void Cocos2dRenderManager::initialise() { CCDirector *pDirector = CCDirector::sharedDirector(); MYGUI_PLATFORM_ASSERT(!mIsInitialise, getClassTypeName() << " initialised twice"); MYGUI_PLATFORM_LOG(Info, "* Initialise: " << getClassTypeName()); CCSize s = pDirector->getWinSizeInPixels(); this->setPosition(0, 0); this->setContentSize(s); setViewSize(int(s.width), int(s.height)); // 绑定到cocos2d节点 pDirector->setNotificationNode(this); mInfo.pixWidth = s.width; mInfo.pixHeight = s.height; mVertexFormat = VertexColourType::ColourABGR; mUpdate = true; kmMat4 tmp; kmGLGetMatrix(KM_GL_PROJECTION, &tmp); kmMat4Inverse(&mMatrix, &tmp); MYGUI_PLATFORM_LOG(Info, getClassTypeName() << " successfully initialized"); mIsInitialise = true; CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(Cocos2dRenderManager::listenForeToBackground), EVENT_COME_TO_BACKGROUND, NULL); pDirector->getScheduler()->scheduleUpdateForTarget(this, kCCPriorityNonSystemMin, false); }
void SchedulerPauseResumeAllUser::pause(float dt) { CCLog("Pausing"); CCDirector* pDirector = CCDirector::sharedDirector(); m_pPausedTargets = pDirector->getScheduler()->pauseAllTargetsWithMinPriority(kCCPriorityNonSystemMin); CC_SAFE_RETAIN(m_pPausedTargets); }
void AutoAttackComponent::stopAttack() { CCLOG("AutoAttackComponent::stopAttack"); CCDirector* director = CCDirector::sharedDirector(); CCScheduler* pScheduler = director->getScheduler(); pScheduler->unscheduleSelector(schedule_selector(AutoAttackComponent::updateAttack),this); }
CCNode::CCNode(void) : m_fRotationX(0.0f) , m_fRotationY(0.0f) , m_fScaleX(1.0f) , m_fScaleY(1.0f) , m_fVertexZ(0.0f) , m_obPosition(CCPointZero) , m_fSkewX(0.0f) , m_fSkewY(0.0f) , m_obAnchorPointInPoints(CCPointZero) , m_obAnchorPoint(CCPointZero) , m_obContentSize(CCSizeZero) , m_sAdditionalTransform(CCAffineTransformMakeIdentity()) , m_pCamera(NULL) // children (lazy allocs) // lazy alloc , m_pGrid(NULL) , m_nZOrder(0) , m_pChildren(NULL) , m_pParent(NULL) // "whole screen" objects. like Scenes and Layers, should set m_bIgnoreAnchorPointForPosition to true , m_nTag(kCCNodeTagInvalid) // userData is always inited as nil , m_pUserData(NULL) , m_pUserObject(NULL) , m_pShaderProgram(NULL) , m_eGLServerState(ccGLServerState(0)) , m_uOrderOfArrival(0) , m_bRunning(false) , m_bTransformDirty(true) , m_bInverseDirty(true) , m_bAdditionalTransformDirty(false) , m_bVisible(true) , m_bIgnoreAnchorPointForPosition(false) , m_bReorderChildDirty(false) , m_pComponentContainer(NULL) // merge CCNodeRGBA , m_displayedOpacity(255) , m_realOpacity(255) , m_isOpacityModifyRGB(false) , m_displayedColor(ccWHITE) , m_realColor(ccWHITE) , m_cascadeColorEnabled(false) , m_cascadeOpacityEnabled(false) , m_drawOrder(0) // touch , m_bTouchCaptureEnabled(true) , m_bTouchSwallowEnabled(true) , m_bTouchEnabled(false) , m_eTouchMode(kCCTouchesOneByOne) { // set default scheduler and actionManager CCDirector *director = CCDirector::sharedDirector(); m_pActionManager = director->getActionManager(); m_pActionManager->retain(); m_pScheduler = director->getScheduler(); m_pScheduler->retain(); m_pComponentContainer = new CCComponentContainer(this); }
void SchedulerUnscheduleAllHard::onExit() { if(!m_bActionManagerActive) { // Restore the director's action manager. CCDirector* director = CCDirector::sharedDirector(); director->getScheduler()->scheduleUpdateForTarget(director->getActionManager(), kCCPrioritySystem, false); } }
/** * 开始移动 * 设置移动动画的定时器 */ void SimpleMoveComponent::startMove() { CCLOG("startMove"); m_moveState=MoveStart; CCDirector* director = CCDirector::sharedDirector(); CCScheduler* pScheduler = director->getScheduler(); pScheduler->scheduleSelector(m_update,this, 0, false); didMoveStart(); }
void AutoAttackComponent::attack() { CCLOG("AutoAttackComponent::startAttack"); if (m_target) { CCDirector* director = CCDirector::sharedDirector(); CCScheduler* pScheduler = director->getScheduler(); pScheduler->scheduleSelector(schedule_selector(AutoAttackComponent::updateAttack),this, m_attackSpeed, false); } }
CCNode::CCNode(void) : m_fRotationX(0.0f) , m_fRotationY(0.0f) , m_fScaleX(1.0f) , m_fScaleY(1.0f) , m_fVertexZ(0.0f) , m_obPosition(CCPointZero) , m_fSkewX(0.0f) , m_fSkewY(0.0f) , m_obAnchorPointInPoints(CCPointZero) , m_obAnchorPoint(CCPointZero) , m_obContentSize(CCSizeZero) , m_sAdditionalTransform(CCAffineTransformMakeIdentity()) , m_pCamera(NULL) // children (lazy allocs) // lazy alloc , m_pGrid(NULL) , m_nZOrder(0) , m_pChildren(NULL) , m_pParent(NULL) // "whole screen" objects. like Scenes and Layers, should set m_bIgnoreAnchorPointForPosition to true , m_nTag(kCCNodeTagInvalid) // userData is always inited as nil , m_pUserData(NULL) , m_pUserObject(NULL) , m_pUserObjectNR(NULL) , m_pShaderProgram(NULL) , m_eGLServerState(ccGLServerState(0)) , m_uOrderOfArrival(0) , m_bRunning(false) , m_bTransformDirty(true) , m_bInverseDirty(true) , m_bAdditionalTransformDirty(false) , m_bVisible(true) , m_bIgnoreAnchorPointForPosition(false) , m_bReorderChildDirty(false) , m_pComponentContainer(NULL) , m_bInformDetach(false) { // set default scheduler and actionManager CCDirector *director = CCDirector::sharedDirector(); m_pActionManager = director->getActionManager(); CC_SAFE_RETAIN(m_pActionManager); m_pScheduler = director->getScheduler(); CC_SAFE_RETAIN(m_pScheduler); CCScriptEngineProtocol* pEngine = CCScriptEngineManager::sharedManager()->getScriptEngine(); m_eScriptType = pEngine != NULL ? pEngine->getScriptType() : kScriptTypeNone; m_pComponentContainer = new CCComponentContainer(this); memset(&m_nUpdateScriptHandler, 0, sizeof(ccScriptFunction)); memset(&m_nScriptHandler, 0, sizeof(ccScriptFunction)); }
/** * 停止移动 * 取消移动动画的定时器 */ void SimpleMoveComponent::stopMove() { // if(m_moveState==MoveStart){ // m_moveState=MoveWillStop; // }else { CCDirector* director = CCDirector::sharedDirector(); CCScheduler* pScheduler = director->getScheduler(); pScheduler->unscheduleSelector(m_update, this); m_moveState=MoveStop; //NSLog(@"stop entity move schedule:update"); didMoveStop(); // } }
void SchedulerPauseResumeAll::pause(float dt) { CCLog("Pausing"); CCDirector* pDirector = CCDirector::sharedDirector(); m_pPausedTargets = pDirector->getScheduler()->pauseAllTargets(); CC_SAFE_RETAIN(m_pPausedTargets); unsigned int c = m_pPausedTargets->count(); if (c > 2) { // should have only 2 items: CCActionManager, self CCLog("Error: pausedTargets should have only 2 items, and not %u", (unsigned int)c); } }
CCNode::CCNode(void) : m_nZOrder(0) , m_fVertexZ(0.0f) , m_fRotation(0.0f) , m_fScaleX(1.0f) , m_fScaleY(1.0f) , m_tPosition(CCPointZero) , m_fSkewX(0.0f) , m_fSkewY(0.0f) // children (lazy allocs) , m_pChildren(NULL) // lazy alloc , m_pCamera(NULL) , m_pGrid(NULL) , m_bIsVisible(true) , m_tAnchorPoint(CCPointZero) , m_tAnchorPointInPoints(CCPointZero) , m_tContentSize(CCSizeZero) , m_bIsRunning(false) , m_pParent(NULL) // "whole screen" objects. like Scenes and Layers, should set m_bIgnoreAnchorPointForPosition to false , m_bIgnoreAnchorPointForPosition(false) , m_nTag(kCCNodeTagInvalid) // userData is always inited as nil , m_pUserData(NULL) , m_pUserObject(NULL) , m_bIsTransformDirty(true) , m_bIsInverseDirty(true) , m_nScriptHandler(0) , m_pShaderProgram(NULL) , m_nOrderOfArrival(0) , m_glServerState(CC_GL_BLEND) , m_bReorderChildDirty(false) #if DEBUG , m_bpcTag("") #endif { // set default scheduler and actionManager CCDirector *director = CCDirector::sharedDirector(); m_pActionManager = director->getActionManager(); m_pActionManager->retain(); m_pScheduler = director->getScheduler(); m_pScheduler->retain(); CCScriptEngineProtocol* pEngine = CCScriptEngineManager::sharedManager()->getScriptEngine(); m_eScriptType = pEngine != NULL ? pEngine->getScriptType() : kScriptTypeNone; }
NS_CC_BEGIN CCNode::CCNode(void) : m_fRotation(0.0f) , m_fScaleX(1.0f) , m_fScaleY(1.0f) , m_fPositionZ(0.0f) , m_obPosition(CCPointZero) , m_fSkewX(0.0f) , m_fSkewY(0.0f) , m_obAnchorPointInPoints(CCPointZero) , m_obAnchorPoint(CCPointZero) , m_obContentSize(CCSizeZero) , m_pCamera(NULL) // children (lazy allocs) // lazy alloc , m_pGrid(NULL) , m_nZOrder(0) , m_pChildren(NULL) , m_pParent(NULL) // "whole screen" objects. like Scenes and Layers, should set m_bIgnoreAnchorPointForPosition to false , m_nTag(kCCNodeTagInvalid) , m_pUserObject(NULL) , m_pShaderProgram(NULL) , m_eGLServerState(ccGLServerState(0)) , m_bRunning(false) , m_bTransformDirty(true) , m_bInverseDirty(true) , m_bVisible(true) , m_bIgnoreAnchorPointForPosition(false) , m_bReorderChildDirty(false) , m_nScriptHandler(0) , m_nUpdateScriptHandler(0) { // set default scheduler and actionManager CCDirector *director = CCDirector::sharedDirector(); m_pActionManager = director->getActionManager(); m_pActionManager->retain(); m_pScheduler = director->getScheduler(); m_pScheduler->retain(); CCScriptEngineProtocol* pEngine = CCScriptEngineManager::sharedManager()->getScriptEngine(); m_eScriptType = pEngine != NULL ? pEngine->getScriptType() : kScriptTypeNone; }
void Cocos2dRenderManager::shutdown() { MYGUI_PLATFORM_ASSERT(mIsInitialise, getClassTypeName() << " is not initialised"); MYGUI_PLATFORM_LOG(Info, "* Shutdown: " << getClassTypeName()); CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->getScheduler()->unscheduleUpdateForTarget(this); // 注意 (maybe)CCNotificationCenter的生命周期在mainloop结束之前就结束了 CCNotificationCenter::sharedNotificationCenter()->removeObserver(this, EVENT_COME_TO_BACKGROUND); // 解除与cocos2d节点的绑定 pDirector->setNotificationNode(NULL); destroyAllResources(); MYGUI_PLATFORM_LOG(Info, getClassTypeName() << " successfully shutdown"); mIsInitialise = false; }
CCNode::CCNode(void) : m_fRotationX(0.0f) , m_fRotationY(0.0f) , m_fScaleX(1.0f) , m_fScaleY(1.0f) , m_fVertexZ(0.0f) , m_obPosition(CCPointZero) , m_fSkewX(0.0f) , m_fSkewY(0.0f) , m_obAnchorPointInPoints(CCPointZero) , m_obAnchorPoint(CCPointZero) , m_obContentSize(CCSizeZero) , m_sAdditionalTransform(CCAffineTransformMakeIdentity()) , m_pCamera(NULL) // children (lazy allocs) // lazy alloc , m_pGrid(NULL) , m_nZOrder(0) , m_pChildren(NULL) , m_pParent(NULL) // "whole screen" objects. like Scenes and Layers, should set m_bIgnoreAnchorPointForPosition to true , m_nTag(kCCNodeTagInvalid) // userData is always inited as nil , m_pUserData(NULL) , m_pUserObject(NULL) , m_pShaderProgram(NULL) , m_eGLServerState(ccGLServerState(0)) , m_uOrderOfArrival(0) , m_bRunning(false) , m_bTransformDirty(true) , m_bInverseDirty(true) , m_bAdditionalTransformDirty(false) , m_bVisible(true) , m_bIgnoreAnchorPointForPosition(false) , m_bReorderChildDirty(false) , m_nScriptHandler(0) , m_nUpdateScriptHandler(0) , m_pComponentContainer(NULL) , m_bClipEnabled(false) , m_oClipRect(CCRectZero) , m_bTouchEnabled(false) , m_bTouchChildren(true) , m_drawOrder(0) , m_pScriptTouchHandlerEntry(NULL) ,_displayedOpacity(255) , _realOpacity(255) , _displayedColor(ccWHITE) , _realColor(ccWHITE) , _cascadeColorEnabled(true) , _cascadeOpacityEnabled(true) { // set default scheduler and actionManager CCDirector *director = CCDirector::sharedDirector(); m_pActionManager = director->getActionManager(); m_pActionManager->retain(); m_pScheduler = director->getScheduler(); m_pScheduler->retain(); CCScriptEngineProtocol* pEngine = CCScriptEngineManager::sharedManager()->getScriptEngine(); m_eScriptType = pEngine != NULL ? pEngine->getScriptType() : kScriptTypeNone; m_pComponentContainer = new CCComponentContainer(this); }