Forum Topic: Reducing lag in AS3

(179 views • 12 replies)

This topic is 1 page long.

<< < > >>
Shouting

SpyreWorks

Reply To Post Reply & Quote

Posted at: 9/3/09 03:26 PM

SpyreWorks EVIL LEVEL 04

Sign-Up: 02/14/09

Posts: 64

I'm planning to make a top-view RTS game in flash AS3, and before I even start, I know that the game will be lag-heavy unless I take some precautions, so I'd just like to ask everyone, what are the best things to do to reduce as much lag as possible in a game? (But keep it good quality, so don't tell me to just get rid of lots of units or something >.>)


None

GustTheASGuy

Reply To Post Reply & Quote

Posted at: 9/3/09 03:38 PM

GustTheASGuy LIGHT LEVEL 08

Sign-Up: 11/02/05

Posts: 11,418

It depends on what the game focuses on and how clever you are.
You have to work around the fuckups of Flash (such as rendering and memory allocation), but the rest is for you to not fuck up.

#ngprogramming at irc.freenode.net
haXe | Keel imperative | Spyro! | Thru you


None

SpyreWorks

Reply To Post Reply & Quote

Posted at: 9/3/09 03:46 PM

SpyreWorks EVIL LEVEL 04

Sign-Up: 02/14/09

Posts: 64

Well, let's say my game is basically Battle For Middle Earth or Age of Mythology, but in topdown flash version.

Got any more specific tips for that? :P


None

GustTheASGuy

Reply To Post Reply & Quote

Posted at: 9/3/09 03:59 PM

GustTheASGuy LIGHT LEVEL 08

Sign-Up: 11/02/05

Posts: 11,418

In that case, try making the game first. You can't find solutions in advance if you don't understand the problems.

#ngprogramming at irc.freenode.net
haXe | Keel imperative | Spyro! | Thru you


None

SpyreWorks

Reply To Post Reply & Quote

Posted at: 9/3/09 04:24 PM

SpyreWorks EVIL LEVEL 04

Sign-Up: 02/14/09

Posts: 64

C'mon, help me out here, aren't there any kind of programming techniques or things to avoid to make a game lag less?


None

Zuggz

Reply To Post Reply & Quote

Posted at: 9/3/09 04:33 PM

Zuggz FAB LEVEL 16

Sign-Up: 06/23/03

Posts: 1,060

At 9/3/09 04:24 PM, SpyreWorks wrote: C'mon, help me out here, aren't there any kind of programming techniques or things to avoid to make a game lag less?

Use other forms of collision detection other than hitTest?
Making your AoE clone will require some trail and error and it depends how advance you want to make it. And what's the unit cap going to be set at.

|- I'm on a Boat - Collab -|- List -|- AS3 -|- Game Poll -|

BBS Signature

None

SpyreWorks

Reply To Post Reply & Quote

Posted at: 9/3/09 04:55 PM

SpyreWorks EVIL LEVEL 04

Sign-Up: 02/14/09

Posts: 64

Well I was hoping for the game to be relatively advanced.
I read somewhere that making units off the screen invisible reduces a lot of lag. Is that true? If no one knows I'll be willing to test it out myself :P


None

zuperxtreme

Reply To Post Reply & Quote

Posted at: 9/3/09 05:02 PM

zuperxtreme NEUTRAL LEVEL 08

Sign-Up: 01/02/05

Posts: 1,625

Only render what you see
Use use the correct variable types(unit vs int, for example)
Try not to next loops

etc
etc
...


None

SpyreWorks

Reply To Post Reply & Quote

Posted at: 9/3/09 05:17 PM

SpyreWorks EVIL LEVEL 04

Sign-Up: 02/14/09

Posts: 64

Okay thanks lol :P


None

Afro-Ninja

Reply To Post Reply & Quote

Posted at: 9/3/09 05:44 PM

Afro-Ninja EVIL LEVEL 38

Sign-Up: 03/02/02

Posts: 13,467

avoid re-creating the same variables over and over again

if you find yourself creating a lot of new variables in loops or enter frame events then you can probably make things more efficient by simply declaring them beforehand and over-writing the same values

avoid repeated calls to display object properties. if you need to use the width or height of something then store it in a separate variable (if it's never going to change). each time you make a call to .width or .height flash has to examine the display object in question and actually find its width or height.

I've heard that turning things invisible off-screen isn't necessary because flash is at least smart enough to know what to render and what not to. but I don't know that for sure.

For any object not growing in size, and not cycling through animation frames, cache it as a bitmap.

BBS Signature

None

Zuggz

Reply To Post Reply & Quote

Posted at: 9/3/09 06:24 PM

Zuggz FAB LEVEL 16

Sign-Up: 06/23/03

Posts: 1,060

At 9/3/09 05:44 PM, Afro-Ninja wrote: I've heard that turning things invisible off-screen isn't necessary because flash is at least smart enough to know what to render and what not to. but I don't know that for sure.

I've had a shit load of stuff going on off screen and it didn't really lag till it hit the stage
So score one for flash on that one.

it's about time.

Try to break up your images into sections not just having one large background if it's really detailed so it only needs to render what's on screen.

|- I'm on a Boat - Collab -|- List -|- AS3 -|- Game Poll -|

BBS Signature

None

SpyreWorks

Reply To Post Reply & Quote

Posted at: 9/3/09 07:18 PM

SpyreWorks EVIL LEVEL 04

Sign-Up: 02/14/09

Posts: 64

Thanks for the tips guys!
I never broke big backgrounds into pieces before, so thanks for a heads up on that one!


None

ImpotentBoy2

Reply To Post Reply & Quote

Posted at: 9/3/09 10:35 PM

ImpotentBoy2 LIGHT LEVEL 18

Sign-Up: 04/01/03

Posts: 5,318

if you have a lot of the same movieClip then take a look at this
http://www.blog.crittercreative.com/?p=5 9

Some times my "L" key decides not to work.


All times are Eastern Standard Time (GMT -5) | Current Time: 05:25 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!