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);
}

 

相关文章:

  • 2021-09-18
  • 2022-03-02
  • 2021-11-04
  • 2021-05-26
  • 2021-05-31
  • 2021-12-06
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2021-09-22
  • 2022-12-23
相关资源
相似解决方案