[haxelib] Provides support for sprite sheet animations
Haxe HTML Shell
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
documentation
examples
spritesheet
src
test/spritesheet/importers
.gitignore
.munit
README.md
TexturePackerImporter.md
clean.sh
fast.sh Adding munit project and other files needed to test logic with OpenFL… Nov 17, 2013
haxe.meta
haxedoc.xml
haxelib.json
project.xml
run.sh
test.hxml

README.md

Spritesheet

Spritesheet is a animation library for animating bitmap sequences in a Haxe projects. Provides support for common sprite sheet importers.

Installation

To install a release build:

haxelib install spritesheet

If you prefer to use development builds:

git clone https://github.com/jgranick/spritesheet
haxelib dev spritesheet spritesheet

To include Spritesheet in an OpenFL project, add <haxelib name="spritesheet" /> to your project.xml.

Usage

It's simple to get started! To see your sprite animating you will need a bitmap, a Spritesheet, and a AnimatedSprite.

Get the BitmapData for your animation

var bitmapData = Assets.getBitmapData("some_sprite_sheet.png");

Spritesheet includes some basic factory methods for common bitmap sprite sheets. This will seed the frames into the Spritesheet.

var spritesheet:Spritesheet = BitmapImporter.create( bitmapData, 3, 9, 56, 80);

Behavior consisting of a name and the cells that should animate

spritesheet.addBehavior( new BehaviorData("idle", [3, 4, 5], false, 15) );

AnimatedSprite sheet will be your view and is added to the stage

var animated:AnimatedSprite = new AnimatedSprite(spritesheet, true)
addChild( animated );

Tell the sprite what behavior to play

animated.showBehavior("stand");

Finally, tell the sprite when to animate and the delta since the last update, in this case we'll be updating via Event.ENTER_FRAME.

private function onEnterFrame(e:Event):Void
{
 var time = Lib.getTimer();
 var delta = time - lastTime;
 animated.update(delta);
 lastTime = time;
}