PDA

View Full Version : [AS3] Optimising my game


carn1x
06-18-2009, 08:12 AM
Hi,

I've been developing a game, for learning purposes as well as fun. The entire game is drawn with line, circle and rectangle sprites, with various transparency effects. Things can get pretty hectic at times with a lot of objects on screen in late game, and the frame rate really takes a hit. So I am trying to create a level of detail setting, for use both dynamically and user set.

To alter the level of detail, I am skipping frames, or removing effects that are only for visual purposes earlier than the max detail equivalent. Another technique, is when for instance a rocketlauncher fires a large spread of missiles, some of the missiles will be hidden along with the rocket trail effect, as rendering more than so many rockets when they are all grouped together with near parallel vectors ends up being fairly wasteful. This is helping somewhat, however I am wondering if there are some global flash settings that I can also exploit? Such as turning off AntiAliasing, how would I do this?

Does anybody have any other ideas or techniques for how to increase frame rate?

I am virtually certain the frame rate hit is to do with object display rather than inefficient coding of the game math behind the scenes, as part of the games control allows the player to hide certain effects by holding the CTRL button. When the game hits a slowdown, I can hit CTRL, remove the expensive layers and the game instantly speeds up. However the purpose of this function is actually to allow the player access to objects on the screen that are underneath the various effects, and I would like to provide the player the opportunity to play the more visually expensive scenarios with reduced graphics, rather than resort to hiding all effects.

Thanks for any help or comments :)

carn1x
06-23-2009, 09:34 AM
just thought I'd post one of the solutions I've found regarding optimising game quality.

import flash.display.StageQuality

then set

stage.quality=StageQuality.LOW
stage.quality=StageQuality.MEDIUM
stage.quality=StageQuality.HIGH (Default)
stage.quality=StageQuality.BEST

haven't found any ways to set quality to certain objects, and anything below HIGH can be pretty horrible to the quality of circles, but there you have it :).

aaron_da_killa
07-06-2009, 07:27 AM
- Keep code running every frame to a minimum.
- Remove objects from the stage that can't be seen.
- Lower the frame rate of the game (but as a last resort) and adjust game according to new frame rate.
- Use local variables instead of global variables where you can.
- Use else if statements instead if multiple if statements where you can.

Also, if the shapes you mentioned are vector based, that's probably where your problem is coming from. Vector based objects result in a smaller size but require more processing power to handle.

But yeah, I've tackled lag in my game by removing what can't be seen from the stage and by not processing what can't be seen. If there is a platform on the other side of the level you don't want to be listening for the player to hit it.