1

I have a CADisplayLink set up for my gameloop that handles the animation loop.

When the game is over I show another storyboard with the game result. At that storyboard the user can choose to Try again. And if so I choose to show the game storyboard again.

How do I pause and resume the CADisplayLink in the correct way? Or should I destroy the CADisplayLink and create a new when the game starts again?

matsmats
  • 502
  • 3
  • 12

1 Answers1

0

How about setting an isRunning property which, if set to NO should force CADisplayLink's handler method to return right away (without calling the code that makes the animation and the game run).

-(void) tick:(CADisplayLink*)
{
    if (!self.isRunning) return;

}
Meda
  • 2,776
  • 4
  • 20
  • 31
  • Thanks. What about memory consumption? Is this ok? And if the game is running in the background, is this ok? – matsmats Sep 29 '13 at 13:54
  • I solved it when I removed the gameloop when the game is over by calling: [updater removeFromRunLoop:[NSRunLoop currentRunLoop] forMode: NSRunLoopCommonModes]; – matsmats Sep 29 '13 at 20:08