1
votes

I'm working on a game using Sprite Kit where the user needs to solve as many puzzles in a given period of time. Every time a puzzle is solved correctly, a new game scene is created with a new puzzle and displayed. I created a timer for the scenes, but it restarts every time a new scene is generated. Is there a way to keep one timer displayed for multiple scenes?

3

3 Answers

1
votes

You should use a singleton file to store this so it will be the only one when you change the scene or anything.

http://www.raywenderlich.com/46988/ios-design-patterns This link will give you the basic knowledge about how to work with Singleton like that.

1
votes

If you have one view controller presenting all the scenes, you can attach the timer to that view controller rather than the scenes.

0
votes

Create and store the timer object and the related data in your view controller instance, or subclass the SKView and store it there. This will retain any object for the lifetime of the view.

Hope helps