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?
Possible to prevent device to go to sleep?
Members - Reputation: 822
Posted 24 August 2014 - 09:48 AM
On android there is an intent you invoke to prevent sleep. I think it's called "prevent sleep."
I used it in this app:
Senior Moderators - Reputation: 12780
Posted 24 August 2014 - 02:36 PM
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?
Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]
Members - Reputation: 1442
Posted 24 August 2014 - 03:21 PM
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.
Crossbones+ - Reputation: 2812
Posted 24 August 2014 - 03:30 PM
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.
Crossbones+ - Reputation: 23815
Posted 24 August 2014 - 08:10 PM
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.
It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal
[Need web hosting? I personally like A Small Orange]