pause和resume

 CCSet *m_pPausedTargets;类的成员变量

void CCNode::schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay)

void PauseResumeActions::onEnter()
{
    ActionsDemo::onEnter();
    
    this->centerSprites(2);
    
    m_tamara->runAction(CCRepeatForever::create(CCRotateBy::create(3, 360)));
    m_grossini->runAction(CCRepeatForever::create(CCRotateBy::create(3, -360)));
    m_kathia->runAction(CCRepeatForever::create(CCRotateBy::create(3, 360)));
    //所有动作在第三秒暂停
    this->schedule(schedule_selector(PauseResumeActions::pause), 3, false, 0);
    //所有动作在第五秒重新开始
    this->schedule(schedule_selector(PauseResumeActions::resume), 5, false, 0);
}
void PauseResumeActions::pause(float dt)
{
    CCLog("Pausing");
    CCDirector *director = CCDirector::sharedDirector();

    CC_SAFE_RELEASE(m_pPausedTargets);
    m_pPausedTargets = director->getActionManager()->pauseAllRunningActions();
    CC_SAFE_RETAIN(m_pPausedTargets);
}

void PauseResumeActions::resume(float dt)
{
    CCLog("Resuming");
    CCDirector *director = CCDirector::sharedDirector();
    director->getActionManager()->resumeTargets(m_pPausedTargets);
}

 

你可能感兴趣的:(res)