iDevGames Forums
2D Game Stutters - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: 2D Game Stutters (/thread-1492.html)



2D Game Stutters - TownDrunk - Apr 6, 2009 05:06 AM

I'm developing a 2D game and I'm using a NSTimer set at 1.0/60.0 to call my gameLoop method. I'm also using the accelerometer, set at 1.0/100.0 to move the player around the screen which seems to be a bit jittery. I should mention that I'm using Core Graphics for all my drawing. ie. offscreen bitmap then I blit that to the screen in my drawRect method of my UIView.

My animated background and sprites (approx. 30 items) seems to move very smoothly when running on the simulator. However, when I run on the iPhone the game starts off running smooth and then I start to get jitters/stutters and sometimes even a pause. I have used instruments to check for leaks and everything looks good there. This is my first attempt at a game. Any ideas on why this would be happening?


2D Game Stutters - SethWillits - Apr 6, 2009 11:42 AM

If you're using Instruments, you can do a speed profile and it'll show you what's slow. It'll surely be the drawing itself.

Trying to draw many things at 60fps with CG on an iPhone likely isn't going to happen. You need dedicated help from the hardware. IOW - OpenGL.


2D Game Stutters - sumiguchi - Apr 8, 2009 03:55 PM

I don't have any idea if this would be the cause but why to you do have such a high frequency for the accelerometer?

It doesn't make sense (to me) to have it set higher than the actual frame rate of the game. I use 1/60 for my timer and 1/45 for my accelerometer and have more than 30 objects on screen with no problem... something easy to try anyways...


2D Game Stutters - TownDrunk - Apr 9, 2009 07:28 AM

sumiguchi Wrote:I don't have any idea if this would be the cause but why to you do have such a high frequency for the accelerometer?

It doesn't make sense (to me) to have it set higher than the actual frame rate of the game. I use 1/60 for my timer and 1/45 for my accelerometer and have more than 30 objects on screen with no problem... something easy to try anyways...

Hmm... not sure why I choose that value. I will give 1/45 a try and see what I get.

Thanks.


2D Game Stutters - TownDrunk - Apr 10, 2009 10:30 AM

TownDrunk Wrote:Hmm... not sure why I choose that value. I will give 1/45 a try and see what I get.

Thanks.

Well... I have been rewriting my game using OpenGL and this has been quite a learning experience. I cannot believe the difference in speed and smoothness. I guess everyone here in the forums who says "you need to use OpenGL..." is right and has probably gone down the same path as I have to get here.

Thanks