Giter VIP home page Giter VIP logo

spritesheet's Introduction

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;
}

spritesheet's People

Contributors

haysclark avatar jgranick avatar mpozzoknx avatar rudolfvonkrugstein avatar stolex avatar supremefist avatar xastor avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.