title: cocos2d-x CCDirector, pause/resume vs stopAnimation/startAnimation
body: <p>First, I need to say, all the following is based on cocos2d-x-2.1.4.</p>
  
  <p>In HelloCpp project of cocos2d-x, you can see it calls <code>CCDirector::sharedDirector()-&gt;stopAnimation();</code> in <code>void AppDelegate::applicationDidEnterBackground()</code>(<a href="https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-2.1.4/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp#L81" rel="nofollow noreferrer">click here to check</a>).</p>
  
  <p>It supposes to stop the animation when app is inactive. And it perform perfectly in iOs.</p>
  
  <p>But in Android, after I called this <code>stopAnimation()</code>, the elements which were running animations will start to blink. And it displayed worse as the device had lower performance.</p>
  
  <p>I then tried to use <code>CCDirector::sharedDirector()-&gt;pause()</code>, it performed not bad, the animations stopped and <strong>NOT</strong> blinked.</p>
  
  <p>So I want to know what the difference between these two method.</p>
  
  <p>In <a href="https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-2.1.4/cocos2dx/CCDirector.h" rel="nofollow noreferrer"><code>CCDirector.h</code></a>, we can see these code:</p>
  
  <pre><code>/** Pauses the running scene.
   The running scene will be _drawed_ but all scheduled timers will be paused
   While paused, the draw rate will be 4 FPS to reduce CPU consumption
   */
  void pause(void);
  
  /** Stops the animation. Nothing will be drawn. The main loop won't be triggered anymore.
   If you don't want to pause your animation call [pause] instead.
   */
  virtual void stopAnimation(void) = 0;
  </code></pre>
  
  <p>Here it says, "If you don't want to pause your animation call [pause] instead.", but in fact, I could pause animation if I called <code>pause()</code>, so I was confused.</p>
  
  <p>And in this <a href="https://stackoverflow.com/questions/11008141/cocos2d-x-game-crashes-when-entered-background">post</a>, it said the app would crash if called <code>CCDirector::sharedDirector()-&gt;pause();</code> in <code>void AppDelegate::applicationDidEnterBackground()</code>. But I had tested it by myself, it did not crash at this version in both iOs and Android.</p>
  
  <p>So, I thought what would happened if I use <code>pause()</code> instead of <code>stopAnimation()</code>.</p>
  
  <p>Then I did some test. Finally I got the result, <code>stopAnimation()</code> performed better than <code>pause()</code> in iOs, but in reverse in Android.</p>
  
  <p>So I wanted to change my code to this:</p>
  
  <pre><code>void AppDelegate::applicationDidEnterBackground() {
  #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
      CCDirector::sharedDirector()-&gt;stopAnimation();
  #elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
      CCDirector::sharedDirector()-&gt;pause();
  #endif
  }
  
  void AppDelegate::applicationWillEnterForeground() {
  #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
      CCDirector::sharedDirector()-&gt;startAnimation();
  #elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
      CCDirector::sharedDirector()-&gt;resume();
  #endif
  }
  </code></pre>
  
  <p>Now can anyone give me some suggestion? Or if it is not good, tell me why.</p>