11

I am pausing my SKScene using the following code:

self.paused = YES;

However, according to this answer by Andrey Gordeev, one can also pause a scene using this line:

self.view.paused = YES;

I would like to understand what difference it would make to call the either (or both) to pause a scene.

Community
  • 1
  • 1
ZeMoon
  • 20,054
  • 5
  • 57
  • 98

2 Answers2

15

Pausing SKView stops calling update: method for SKScene.

Pausing SKScene doesn't do that.

I usually pause both SKScene and SKView

EDIT:

As of iOS9 pausing the scene will pause the update: method.

Whirlwind
  • 14,286
  • 11
  • 68
  • 157
Andrey Gordeev
  • 30,606
  • 13
  • 135
  • 162
  • I confirmed this by using NSLog() in the update method. Thanks Andrey for clearing this up. – ZeMoon Apr 30 '14 at 11:33
  • Pausing SKScene stops all actions running on the node and its children. Therefore both are usually called together. – jokkedk Dec 06 '14 at 17:18
  • This is not the case anymore... In iOS9, the `update:` method is not executed while the scene is paused. You could make an edit about that for the future readers. The other part (about SKView) is of course correct and I guess that will never change :) – Whirlwind Mar 26 '16 at 00:07
  • @Whirlwind go ahead and edit an answer! Unfortunately, I don't work with `SpriteKit` now :) – Andrey Gordeev Mar 26 '16 at 06:49
  • 1
    I'm developing a game with gravitation simulations and actually the difference is noticeable. If you pause/unpause the SKView quickly you get an uncomfortable jitter, like a bug. Pausing/unpausing the scene itself it's a lot smoother. – Bernardo Santana May 05 '16 at 15:40
2

The effect is the same. You still have the paused property on the scene because it's a subclass of SKNode and the scene may need to be paused during transitions, either through the SKView setting that controls whether scenes are paused during transitions or manually.

I would wager that pausing the view would also be able to "freeze" a currently running transition, which is about the only thing you can't pause by pausing the scene(s) alone.

Therefore pausing the view may also pause all internal timers and draw calls, so a paused view may be better to conserve battery, though that's a guess based on how cocos2d handles a paused director vs paused scene.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217