Hi everyone,
I just had a quick question about improving the performance of my app. I made a simple little game and although it runs, it does have a relatively low framerate. I've set acceleratedRendering to true and the graphics that I am using have also been set to dynamic.
I've been testing the app on both a Galaxy S1 and Galaxy S3 for low and high performance devices but they seem to both run almost the same. Does anyone have any ideas on how to further improve the performance of this app from a very generic standpoint?
Any help would be much appreciated! Hope everyone has a happy new year!
Improving Overall Performance
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Improving Overall Performance
Hard to say without seeing some code, but since you're asking for general thoughts, here goes.
If you are using any repeat loops, depending on the circumstances, repeat for each will be much faster than repeat with i = 1 to whatever..
If you are moving multiple objects on the screen each frame, and/or multiple updates to fields or basically any kind of multiple screen change (even simple changes benefit from this) make sure you use lock screen, do the changes, unlock screen to show the new "frame"
If you are doing collision checks with multiple objects it can be faster to to determine if there is a possibility of an intersect before actually calling the intersect function. For example, if you have created a right to left scroller, (terrain scrolls to the left) you can check the left side of an object against the right side of the player to see if things have moved far enough for there to perhaps be a collision. (I think you can create a lookup table for this sort of thing also, but i've never done it)
If your game uses a game loop, you might look in to using elasped time to calculate new positions rather than an "every frame, move it this far" type of method so that if there is a momentary bog, on the next frame the objects still appear at the correct locations.
while repeat loops can be necessary, overuse can be bad. Its possible to give breathing space in a repeat loop using a "wait 0 with messages" but this can actually slow things down overall. If a repeat loop is causing trouble, it might be worth a rethink.
log start and end times in handlers so you can locate bottlenecks. Its much easier to locate where your holdups occur this way. If you find some slow sections of code, post the handlers here and i'm sure there will be a load of ideas for increasing performance.
If you are using any repeat loops, depending on the circumstances, repeat for each will be much faster than repeat with i = 1 to whatever..
If you are moving multiple objects on the screen each frame, and/or multiple updates to fields or basically any kind of multiple screen change (even simple changes benefit from this) make sure you use lock screen, do the changes, unlock screen to show the new "frame"
If you are doing collision checks with multiple objects it can be faster to to determine if there is a possibility of an intersect before actually calling the intersect function. For example, if you have created a right to left scroller, (terrain scrolls to the left) you can check the left side of an object against the right side of the player to see if things have moved far enough for there to perhaps be a collision. (I think you can create a lookup table for this sort of thing also, but i've never done it)
If your game uses a game loop, you might look in to using elasped time to calculate new positions rather than an "every frame, move it this far" type of method so that if there is a momentary bog, on the next frame the objects still appear at the correct locations.
while repeat loops can be necessary, overuse can be bad. Its possible to give breathing space in a repeat loop using a "wait 0 with messages" but this can actually slow things down overall. If a repeat loop is causing trouble, it might be worth a rethink.
log start and end times in handlers so you can locate bottlenecks. Its much easier to locate where your holdups occur this way. If you find some slow sections of code, post the handlers here and i'm sure there will be a load of ideas for increasing performance.