Pretty banner! :)

Improving Performance with Animated Bitmaps

Valuable Tools The built in MovieClip class is slow and bloated. For most high performance situations in a dynamic real time game, it is not going to going to perform well enough if we have lots of intense animations. Today’s article is going to try and establish a specification for an Animation library that uses BitmapDatas for maximum performance.

Design Methodology

I endeavored to start this spec using the MovieClip class as the basis for the design, but ultimately I felt it was limiting enough to abandon it. We are looking for a replacement for the built-in MovieClip class, except it is designed to maximize run-time performance.

Over the last few years I’ve built a few animation systems but I’ve never been happy enough with the design to turn it into a reusable library. My goal here is to establish the core of the animation spec and then build future tools that utilize this core to create a mature, reusable bitmap animation system.

The Core Classes

The essence of our animation system is its interaction with our game engine which is accomplished with the following core classes:

  1. AnimationController
  2. IAnimation (with a BitmapAnimation and maybe a MovieClipAnimation implementation)
  3. AnimationEvent
  4. FrameEvent

AnimationController will inherit from Bitmap. It has the following properties:

addAnimation( a_animationID : String, a_animation : IAnimation );
play( a_animationID : String ); // switches playhead to this animation immediately
stop(); // stops the active animation
update( a_ms : Number ); // updates the animation
queue( a_animationID : String ); // adds the id to an animation queue
                        // when the active animation completes
                        // the next animation in the queue is begun
defaultAnimationID : String; // this is the animation that begins
                           // playing whenever another animation
                           // that isn't looping completes

IAnimation has the following properties:

update( a_ms : Number );
isLooping() : Boolean;

BitmapAnimation has the following properties:

addFrame( a_frameID : String, a_playTime : Number, a_bitmapData : BitmapData, a_frameLocation : Rectangle );

AnimationEvent has the following properties:

begin : Boolean; // true if the animation has started, false if it has ended
animationID : String;

FrameEvent has the following properties:

begin : Boolean;
frameID : String;
animationID : String;

Tools For Generating Tile Sheets

These classes describe how we interact with our system at the engine level. It is far more convenient for us to use this system if we have tools that can generate Animations for us. The Single Responsibility Principle dictates that we build these helpers as separate classes. This will improve the modularity of our code and make it more robust if there are engine or format changes in the future.

At a high level, the most useful tool would load a bitmap, let us specify some animations using a combination of UI widgets and drag-dropping on the bitmap, and it would then export an engine readable format that we can use to to generate the runtime representation of our bitmap animations. A necessary component of this tool, and a higher priority objective, is an XML spec that this tool would generate that defines all the animations and then a runtime component that turns this XML data into an AnimationController.

Volunteers?

It’s a lot of work, that’s for sure, which is why this article starts with just a specification. I’ll work on this slowly over time, or if I have an opportunity to bang it out on another project I’ll tackle it then. Another option is you can volunteer to help me out, in which case I’ll make it worth your while (think $s). If you’re interested, e-mail me at panayoti.haritatos |@| urbansquall.com. Without the pipes. ;)

Post Metadata

Date
October 31st, 2008

Author
urbansquall

Category


3 Trackbacks & Pingbacks

  1. February 21, 2009 2:08 pm

    Interactive Crap » Ginger: Using it for uniform sprite sheet rendering :

  2. February 21, 2009 2:54 pm

    Ginger: Using it for uniform sprite sheet rendering « Gametastic: The TryCatch Blog :

  3. September 2, 2009 9:01 am

    Cheezeworld » Bitmap Animation API Released – Ginger :

0 Comments

Leave a Reply