Timer Slows down in sleep mode

Member
Posts: 43
Joined: 2009.04
Post: #1
ok i am using an nstimer for my game, and i want the game to continue when it is in sleep mode. The game still runs in sleep mode but not @ normal speed, does anyone know how to fix this problem?
Quote this message in a reply
Moderator
Posts: 508
Joined: 2002.09
Post: #2
Unless you have a really good reason why your game should be running in sleep mode, you really shouldn't. That's the whole purpose of sleep mode!

Imagine the face on your users when they see that their iPhone's battery has been drained because of your game. They'll quickly remove it and never play it again.

"When you dream, there are no rules..."
Quote this message in a reply
Member
Posts: 43
Joined: 2009.04
Post: #3
I do have a good reason: it us going to be part of the game, and I am going to notify the userSmile so please help
Quote this message in a reply
Moderator
Posts: 508
Joined: 2002.09
Post: #4
notify the users of what? Your notifications will not serve of anything when the device is put to sleep. I recommend checking your game design again, because what you're trying to do is not good.

"When you dream, there are no rules..."
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #5
This is in strong contrast to the Human Interface Guidelines for mobile development. I doubt Apple would allow a game that functions like this.

Kyle Richter
DragonForged.com
Twitter: @kylerichter
Quote this message in a reply
Member
Posts: 43
Joined: 2009.04
Post: #6
i want the games timer to keep going because thats how i keep score and if it turns that off it will be screwed up
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #7
chrism Wrote:i want the games timer to keep going because thats how i keep score and if it turns that off it will be screwed up

Your app is not suppose to keep running while in sleep mode, please read the HIG

Kyle Richter
DragonForged.com
Twitter: @kylerichter
Quote this message in a reply
Member
Posts: 43
Joined: 2009.04
Post: #8
I know there is a way to stop sleep mode, but does it stop sleep mode even when you press the sleep button?
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #9
chrism Wrote:I know there is a way to stop sleep mode, but does it stop sleep mode even when you press the sleep button?

You can set the idle timer so the phone does not automatically sleep for 10 minutes but you can not override the hardware switch.

Kyle Richter
DragonForged.com
Twitter: @kylerichter
Quote this message in a reply
Member
Posts: 43
Joined: 2009.04
Post: #10
Thanks you were a big help. Oh and sorry for me being so hard headed sometimesLOL
Quote this message in a reply
Member
Posts: 32
Joined: 2008.10
Post: #11
a) your program wont be scheduled to run when the phone is sleeping.
b) save a time snapshot when the phone goes to sleep, and read the time when awaken. Do your update then and there. User happy, peace on earth...
Quote this message in a reply
Member
Posts: 43
Joined: 2009.04
Post: #12
Great idea can you tell me the kind of code I will need so I can check documentation
Thanks
Quote this message in a reply
Moderator
Posts: 508
Joined: 2002.09
Post: #13
Check UIApplication's delegate methods and you will know where to place the code Wink

"When you dream, there are no rules..."
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #14
Your application does run, at the same speed, while the phone is sleeping.

I imagine, because you are writing a game, you chose the OpenGL ES Template. This template has code that slows down the timer to 5 times per second when the application is no longer active - like when a phone call comes in or the phone goes to sleep.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Timer and Touch Event concurrent issue claudie 7 4,162 Aug 9, 2009 06:05 PM
Last Post: claudie
  Sleep Mode never interrupting my game Madrayken 4 2,866 Jul 13, 2009 07:17 AM
Last Post: Madrayken
  Sleep mode kendric 2 2,551 Jul 2, 2009 12:18 PM
Last Post: kendric
  iphone watchdog timer macnib 5 4,181 May 10, 2009 10:58 PM
Last Post: kodex
  game slows down crystal 3 2,544 Feb 20, 2009 12:46 PM
Last Post: longjumper