1

I want to Pause a CCNode for a while and after that resume it again. when I use below code separately they work but when I want to resume this CCNode for a specific time when a button clicked it dose't work and occur an Assertion failed(that is: pElement->paused == bPaused ).

//for pausing
this->pauseSchedulerAndActions();

//for resuming
this->resumeSchedulerAndActions();

I use below codes:

    #define TIME_FOR_RESUME  5.0f
    //function that called when my button click
    void myClass::myFunc(CCObject * pSender)
   {
    this->pauseSchedulerAndActions();
    this->scheduleOnce(schedule_selector(myClass::myResumeFunction), TIME_FOR_RESUME);
    }

   void myClass::myResumeFunction(float dt)
   {
    this->resumeSchedulerAndActions();
   }
CodeSmile
  • 64,284
  • 20
  • 132
  • 217
HRZ
  • 98
  • 7
  • it says : pause scheduler and actions .... I doubt the myResumeFunction will be called. What do you mean 'pause a CCNode' ? maybe this is not the right approach. What is in the node, etc ... – YvesLeBorg Jul 06 '14 at 10:08
  • yes I insert a breakpoint in myResumeFunction but it dose't call and before that an Assertion failed. I mean pausing all the CCSprite and their scheduler's which seems it's not existing for a while and then resume all of them. – HRZ Jul 06 '14 at 10:59

1 Answers1

1

you can use this for pausing

this->unscheduleAllSelectors();

and this for resume

this->scheduleUpdate();
Bheid
  • 306
  • 3
  • 11
  • pause: pauseSchedulerAndActions(); unscheduleAllSelectors(); resume:resumeSchedulerAndActions(); scheduleUpdate(); – zszen Apr 23 '15 at 16:50