Performance / Optimization
madmassey
Member Posts: 55
So I've been reworking the core prototype stuff in my project file for efficiency before I go out and start doing all the gameplay, and I had a few questions about optimization. I went through the project file to remove spawning / destroying and it almost seems like performance is worse on my 3GS. So I was wondering if any of these things could cause performance issues -
- I increased the height of my main test scene to fit all the entities that I was previously spawning... so instead of 960x320, it's 960x576. Could this cause significant problems? Especially if the width of the scene got up to 2400 or so?
- To help conserve space and make my project clean, I shrunk all my actors down really small, and am changing their size attributes before displaying them on the main screen. So, for a full screen image, the image file is 960x640 (resolution independence), the size I expand it to once it's in use is 480x320, and the size I store it in in my project is 75x50.
- On that note, could using resolution independence in general have a negative impact on the performance of lower end hardware?
- Whenever I expand an image, I leave it there with an alpha value of 0 on the main scene in front of the camera... so I'm not constantly moving it off and on the screen, just hiding it. But with several actors with alpha channels overlapping each other, I'm concerned that alpha overdraw may be an issue.
And any other general performance tips (sans the spawning/destroying thing) would be nice. Any help would be greatly appreciated!
- I increased the height of my main test scene to fit all the entities that I was previously spawning... so instead of 960x320, it's 960x576. Could this cause significant problems? Especially if the width of the scene got up to 2400 or so?
- To help conserve space and make my project clean, I shrunk all my actors down really small, and am changing their size attributes before displaying them on the main screen. So, for a full screen image, the image file is 960x640 (resolution independence), the size I expand it to once it's in use is 480x320, and the size I store it in in my project is 75x50.
- On that note, could using resolution independence in general have a negative impact on the performance of lower end hardware?
- Whenever I expand an image, I leave it there with an alpha value of 0 on the main scene in front of the camera... so I'm not constantly moving it off and on the screen, just hiding it. But with several actors with alpha channels overlapping each other, I'm concerned that alpha overdraw may be an issue.
And any other general performance tips (sans the spawning/destroying thing) would be nice. Any help would be greatly appreciated!
Comments
actors can be dragged to scene and then moved to the surrounding grey area and still always be accessible for play.
just changeAttributes for X and Y. this is totally unnecessary work ...the images are loaded at runtime in the size initially imported... the only in important size is the display size... making them smaller and then larger only increases the work the device has to do... and the programming you do! yes... but devices not upgraded to iOS4.0 ... may have performance issue with any intense game. whether you change the Y to -200 or the alpha to 0 ... the gameEngine still has to do something ... as the X and Y are always in memory... think it is better to change one of them. and avoid display clutter and conflicts with layers, etc. ah @madmassey... you are putting a terrific amount of effort into your project... I commend you!
use ImageOptim to cleanup gfx...its Free
MH
If anybody is curious about any of this stuff... It seems like changing image size and XY coordinates are both very cheap performance wise. Scene size, who knows. I'll just make it bigger as I go on until it starts to hitch I guess.
As I suspected though, a HUGE framerate killer is overdraw. When I had all the UI elements initialize invisible in the middle of the screen, performance was totally shot. I then set it up to move elements to the same coords offscreen, and it got a little better but still had issues. So I tried moving the stuff offscreen and making sure that nothing at all was overlapping once off screen and got a rock solid 60 fps. That sort of thing is a big problem in 3D games too, when you have a bunch of trees or shrubs made with alpha planes packed into an area. Of course, maybe touching 10 overlapping actors is bad in general as well.
One of the things I'm wondering about is a jagged border I have for my scenes. It is 480x320 with most of it transparent (ie: the middle where gameplay takes place). Any idea if this would be better achieved performance wise with four images of smaller size .. one each for each side (ie: top, bottom, left and right)?
create an integer attribute (call it zero) and give it a value of 0
When zero = ceil( selftime x 2) %2
... change attribute
The % means modulo. The x2 means the attribute change will occur every second. So put in higher values for the change to take place more often.
Still need to test the performance figures. But from what I've read using the game or self timers is better than adding additional ones.
1. Opening scene is four panels with camera move to show game logo then two level choosing panels and a options/settings panel.
Was: getting FSP of 14.5 with Images 25.8megs. Took out one border that was a full scene image size 12kb .png
Now: FSP 47.5 images 20.8megs (so removing one overlapping 12 kb image resulted in that performance size change
2. GAME scene is a three panel with camera move
WAS: FPS 42 Images 19.3megs
Now: removed borders FPS 58 , images 11.3
deduction: major performance hit from overlapping images. I am going to compile some more before and after tests and see if I can come up with a selection that could really help people make the right choices. Would appreciate if others would like to join in. I think to be effective and accurate we would need to just change one element so you are comparing the original to one type of change to see the effect.
Also, after some more testing on my own stuff, I think spawning and destroying actors can be a positive thing for actors that have a ton of rules, assuming you're only spawning and destroying them once. Because even if it doesn't free up resources image wise, it doesn't have to deal with all the rules simultaneously.