Jump to content
  • Advertisement
Sign in to follow this  
mileafly

Possible to prevent device to go to sleep?

This topic is 1369 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am doing a concept for an "idle game" where the game is supposed to be playing itself apart from doing upgrades and stuff. This works well on desktop and browsers. But I think there will be a problem with mobiles that go to sleep if left alone. Is it possible to disable sleep mode somehow?

Share this post


Link to post
Share on other sites
Advertisement

Feasibility aside, many mobile users will be very upset if you run their battery down to zero by inhibiting sleep...

 

What's to stop you designing the game in such a way that the simulation can progress even if the screen is off?

Share this post


Link to post
Share on other sites

Don't prevent the app from going to sleep.  Horrible thing to do.  iOS/Android will let you know when the app is going to be deactivated and then brought back to the front.  Save your state when the game is going away and then calculate the difference when it comes back. 

 

For iOS the UIApplicationDelegate has 'applicationDidEnterBackground' and 'applicationWillEnterForeground' (also applicationWillResignActive/applicationDidBecomeActive).  And for Android the Activity has 'onStop' and 'onResume'.  Any decent third party engine will bubble those events up to the client code in some form.

Share this post


Link to post
Share on other sites

On iOS, there's [[UIApplication sharedApplication].idleTimerDisabled = TRUE;

 

This is designed for preventing screen fade when watching FMVs, or if your input is purely tilting. It might be suitable for your case, but as others suggest, you shouldn't leave the sleep timer disabled for any longer than necessary.

 

Ultimately though, if your gameplay involves not touching the screen for long periods of time, then idleTimerDisabled is the right thing to use.

Share this post


Link to post
Share on other sites

Could you design the game so that the game remembers the last time it was used (i.e. 9:09 PM 2014/8/24), and interpolates what "happened" the next time the user logs in? This would solve your problem (even when people shut down their desktops) and annoy users less. I wouldn't even want a browser page open continuously even on my desktop, unless it's something important.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!