Reputation: 1296
I am making a game which is based on an NSTimer calling the main loop at 40 fps, and when I run it, even on the newest iPod touch, it still lags a noticeable amount. Would it be possible to use multithreading to reduce lag without reducing the framerate, or is multithreading just for keeping the ui responsive when doing complex calculations? And if it could be used, could you point me to a tutorial on how it would be implemented?
Upvotes: 1
Views: 756
Reputation: 8109
please dont make a game which require high FPS with UIKIT. if its a 2D game you need to go for Quartz either or COCOS2D(which is OpenGL based) and if its a 3D then as @Ajeet suggested you should user OpenGL or look for 3d Engines available for iOS for high FPS.
Upvotes: -1
Reputation: 4254
In general, it's recommended that you move time-consuming operations off of the main thread. The main thread handles the user interface of your application, and if you block that you will prevent standard UI elements from updating and touch events from registering. Depending on how much processing is being done behind the scenes for your game (physics, AI, etc.), you may need to move significant chunks of that to a background thread.
Multithreading is not a simple topic, but Apple has made this a lot easier through Grand Central Dispatch, so I highly recommend reading their Concurrency Programming Guide which describes this and other techniques for achieving multithreading in your application
Apple has an entire section entitled "Concurrency and OpenGL ES" in their OpenGL ES Programming Guide for iOS. In that, they describe several scenarios for improving performance of an OpenGL ES application using multithreading.
Upvotes: 5