iDevGames Forums
Touches are slowing down game - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: Touches are slowing down game (/thread-228.html)

Touches are slowing down game - Jamie W - Mar 23, 2010 04:57 PM


I've got my game running quite nicely, but everytime I touch the screen (or move fingers on screen etc), it slows the game down. I'm testing on hardware, on an iPhone 2g device. I tried in release and in debug mode; and also 3.1.2 and 3.1.3.

Any suggestions, as to what could be causing this?


Touches are slowing down game - skyhawk - Mar 23, 2010 06:17 PM

well, that would depend on what you have your touches (begin and move) functions doing.

Touches are slowing down game - Skorche - Mar 23, 2010 06:54 PM

I seem to recall seeing that happening too. Even if I wasn't catching and using the touch events, I could quite measurably increase the CPU usage of my game by wiggling my finger around on the screen. IIRC it was something like 5-10%. Given that I wasn't doing anything with the events, I really just assumed that there was nothing more that I could do about it and moved on.

Touches are slowing down game - Frank C. - Mar 23, 2010 09:50 PM

Same conclusion as Skorche. All you can really do is tune your animation loop to ensure the event loop can "breathe". Blocking too much can cause events to queue up in bunches and make things even worse.

Touches are slowing down game - Skorche - Mar 24, 2010 05:42 AM

Yeah, I'd really love to know why it blocks events like that. Super frustrating.

Touches are slowing down game - Jamie W - Mar 24, 2010 02:16 PM

Not sure what you mean by blocking events (bit of an iPhone newbie to be honest). I'm not really doing much though, on touchesBegan/Moved/Ended etc; just storing the touch data (which I use elsewhere, later).

I tried running my game at 30hz, which I can't notice any slow-down from the touches, but then of course, the animation is slightly 'blurred'. That's on am iPhone 2G though, which I think may be the lowest powered device there is?

I think the system processing the touches, may just push the amount of processing per frame, over the edge (and so it drops out of 60hz).

I may end up running at 30hz on a 2g and 60hz of 3g or 3gs. Guess it depends on the relative processing power of the devices.

There's also a good chance I don't know what I'm talking about; again, I'm very much an iPhone newbie. Smile

Touches are slowing down game - Skorche - Mar 24, 2010 03:11 PM

If you use too much CPU on the iPhone it sometimes stops sending touch events to your app. Then after storing them up for 10-20 seconds it sends them all in one big lump. I've noticed it in my games and in other peoples games. It seems that there isn't really anything you can do about it other than to add some extra wait times into your game loop so the CPU idles for a few milliseconds once in a while and lets whatever part of the OS that sends the touch events to catch up.

Touches are slowing down game - Smilediver - Mar 26, 2010 07:26 AM

You can't do much about it. Processing touches takes CPU time, and this happens somewhere on iPhone OS. You can't control that. There are ways to limit the time frame given for it, but you'd need to rewrite your game loop to run it manually (google more info about NSRunLoop). And it's not advised, because limiting time on it can ruin responsiveness. Just make sure it's not having a huge impact on gameplay experience and you'll be ok.

Touches are slowing down game - Jamie W - Mar 26, 2010 03:41 PM

Just an updade.

Game is running smooth @ 60hz now, thanks to the CADisplayLink thingy. Before I was just using NSTimer, which I think it begins putting the backbuffer frame together at any point during the current display refresh (rather than at the start of the current display refresh). So the OS processing the touches was just pushing it over the edge. Or at least, that's my best guess / explaination.

Cheers, Smile