Game Development Community

Keep lights on on iPod

by Muthuraja · in iTorque 2D · 07/21/2009 (9:25 pm) · 5 replies

It's me again. I make a game using the accelerometer. This game doesn't need any touch after the play button touch. After 30 seconds iPod turns the lights off. How to keep them on? Help me....

#1
07/24/2009 (1:49 am)
I believe the problem is that iTGB does not report accelerometer actions back to the iPhone / iPod Touch as active calls, therefore the device thinks it is receiving no input and dims the screen, then eventually goes into sleep mode. I remember looking at this once before but didn't need to fix it at the time, but the fix should be very easy. Just look in the engine code and see how screen touches and button inputs are reporting their data back to the iPhone, then add that same code to anywhere we do accelerometer input.

Also - why are you asking questions about iTGB without having purchased a license for the engine? Please purchase the engine if you want to continue to receive support and assistance. Otherwise, don't expect many people to help you, and if you do release a game, I wouldn't be surprised if you get in some legal trouble and Apple is forced to pull the kill switch on your product, which removes it from every device it is installed on.
#2
07/24/2009 (9:19 pm)
@Dave: The correct way is setting the idletimer off in the shared application. I hope this is in the next iTGB release.

@muthuraja: Did you buy iTGB and get a problem with the user account, or are you stealing?
#3
07/24/2009 (9:32 pm)
Ah! Right, that was it! My bad... I knew I had seen how to but had not implmented it.

Shouldn't be too hard to add a #define that defines if the game is accelerometer driven or not to watch the idletimer.

Buuut... Technically, if the idletimer is off, then the device will never go to sleep, which is no good. So really, shouldn't the idletimer be integrated to be reset by accelerometer actions if the game is acceleromete driven?
#4
07/25/2009 (11:16 am)
No, the accelerometer should never have anything to do with the idletimer. For games, you should enable the idletimer when in pausemode, for example. The accelerometer ALWAYS has changing values, unless you are a robot living far away from Japan or California ;)

It's easier to just toggle the idletimer depending on mode, as suggested in "iPhone Application Programming Guide", page 22.

Since the idletimer is fairly short by default, all games should disable it while in playmode. An example would be one of the defensive games where you build units, then sit around for ages while your troops/towers clobber the waves of enemies. If they don't do anything with the timer, the screen dims, and eventually it falls asleep, while you're technically playing.

What iTGB needs is an actual pause/unpause function (like Cocos2D has) which both toggles the idletimer and sets updates to happen less frequently.

So at gamestart and unpause:
[UIApplication sharedApplication].idleTimerDisabled = YES;

...then set it back to NO when pausing/leaving back to the menus. iPhoneMain.mm or thereabouts should have some function calls you can stick this line in.
#5
07/25/2009 (12:26 pm)
Okay, yes, that I can agree with. See, I was working off the logic that I'm not sure if Apple will approve a game that does not go into sleep mode. But then, I know there are non-jailbreak apps that prevent the sleep mode from activating, so I guess that is fine after all. So what you say then makes sense - disable it while in actual playmode, re-enable it while in menus or when your actual game is paused.

(And I very well may be a robot living far from Japan or California. I can keep my hands still enough to crack an atom open like an egg!)