I’m making a package called [FONT=“Courier New”]net.rezmason.blix[/FONT] that simplifies bitmap use in AS3. For instance, if you have a sprite sequence of a dude walking, and the frames are in a single image, my MovingBitmap class lets you turn it immediately into an animation, without messing around with MovieClips or keyframes. It keeps the source bitmap intact, and “blits” data from it onto a “surface”, which is in the display list.
There are a few advantages to using this package:
[LIST]
[]Animations without MovieClips = no Timeline-generated cyclical garbage (my perpetual nemesis)
[]Artists during a game development project will have less to worry about
[]Doing away with Timeline-based animation helps free the developer and artist from the Flash authoring environment (so it will be easier to develop a game outside of Flash, and publish it with mxmlc)
[]MovieClips don’t do custom framerates
[/LIST]
So far I have the MovingBitmap class, which has your standard timeline control functions like stop() and gotoAndPlay() (plus “yalp()” and “gotoAndYalp(n)” for playing in reverse), and a class called SpinningBitmap, which takes a series of rotational sprites and picks from them when assigned a rotation. For instance:
var source:Source = new Source(0, 0); // an image from the Library
var rect:Rectangle = new Rectangle(0, 0, 32, 32);
var demo:SpinningBitmap = new SpinningBitmap(source, rect, false);
addChild(demo);
demo.rotation = 60;
Let’s assume that the source image is of dimensions 128 x 128. That’s sixteen frames of an animation of a 32 x 32 pixel object rotating about its center. When demo.rotation is set to 60, the SpinningBitmap instance converts that angle to a ratio (60/360 = 1/6) and finds the frame in the animation sequence 1/6th from the beginning (1/6 * 16 = approx. 3). Then it draws that frame. This makes the handling of rotational sprite animation a breeze.
Furthermore, if the Boolean parameter of the SpinningBitmap constructor is set to true, then the animation will be interpreted as the rotation of an object from 0 degrees to 45 degrees. When demo.rotation is set to an angle greater than 45, the animation is reflected and rotated to complete the circle. This is convenient when the object you’re rotating is symmetrical, so your sprite artist only has to draw 1/8 of a full rotation.
This is going to be free and open source, so I’d like to know what other things I should throw into this library. My intent primarily is to strengthen Flash’s bitmap functionality for game developers; if there’s a general behavior or feature that you’d like, I’ll cook up a class and stick it in.
If you’d like to see the blix library as it currently stands, let me know and I’ll post it.