Lee
Lee

Reputation: 97

How to develop high-performance flash game?

1.How to load image resources? And in which case we should use "[Embed]" to insert resources?
2.which technology can improve the performance of the game flash game development ?

Upvotes: 0

Views: 254

Answers (3)

Marty
Marty

Reputation: 39456

I find that it all comes down to rendering in the end.. The more vector graphics you use the slower it gets. It makes a ridiculous difference for me if I either move to sprite sheets, or create a class that uses a single MovieClip as a resource for multiple BitmapData objects to draw from.

What I mean is: Say you have a MovieClip for a game enemy like a ship or something. Firstly, create one instance of the MovieClip somewhere that is easily accessible. From here, all of your Ship objects could extend Bitmap. Another feature would be maybe a rendering controller that applies rotation and sets the frame of your ship movieclip. From here, Ship could work similar to this:

public class Ship extends Bitmap
{
    /**
     * Constructor
     */
    public function Ship()
    {
        /**
         * 1. specify the source movieclip thats been set up in RenderClassThing
         * 2. set the rotation to 45 degrees
         * 3. set frame of source movieclip to 4
         */
        RenderClassThing.prepare(shipMC, 45, 4);

        // applies bitmap
        bitmapData = RenderClassThing.getBitmapGraphics(shipMc);
    }
}

This will make a massive difference if you use a lot of vector graphics.

Upvotes: 0

Adam Smith
Adam Smith

Reputation: 1937

Doing more with bitmaps, and in some cases, it might help to compile computationally intensive routines from C code using Alchemy (for collision detection and physics issues, especially).

More than anything else though, you will benefit from using the Flash Builder (or 3rd party) profiler, and other forms of benchmarking to figure out what you need to improve on. There is no substitute for knowing the limitations of your platform and having a nice bag-o-tricks from experience.

Upvotes: 0

Michiel Standaert
Michiel Standaert

Reputation: 4176

Use loaders to access external images, like this:

private function init():void
{
    loader = new Loader();  
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleLoaderCompleteEvent);
    loader.load(new UrlRequest("someImage.jpg"));
    addChild(loader);
}

private function handleLoaderCompleteEvent():void
{
    //Do something.
}

regarding the technologies: if you want some nice animations in your game, use the TweenLite-library, which is awesome for animations. If you want to use 3D, use Papervision3D or away3D, but that requires some studying and getting to know the libraries, as where TweenLite is easily accessible and used.

Upvotes: 1

Related Questions