Tuesday, April 26, 2011

FRAME RATE AND FILTERS

Drawing is slow

Any time there’s a change on the screen, remember: Flash has to redraw all those pixels. Sometimes, setting your game’s frame rate to 24fps can actually make it run more smoothly than at 30fps, because there’s a little extra time each frame to do all the drawing work.

Alpha is a source of lag. If you’ve got a semi-transparent object (object.alpha = 0.5) then Flash has to draw that object and the object behind it:

screenshot

Graphical filters require a lot of work on Flash’s part, too. Calculating (and then drawing) a glow, a shadow, or a blur is a heavy operation.

screenshot

Do you need to apply these effects on the fly? Often you can generate them in Photoshop beforehand.

When you’ve got a lot of objects on-screen at once, it can even be faster to bypass Flash’s built-in drawing routines altogether, and write your own.

No comments:

Post a Comment