Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
License
=======

The MIT License (MIT)

Copyright (c) 2013-2014 Spritesheet contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
113 changes: 77 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,97 @@
# Spritesheet
Spritesheet
===========

Spritesheet is a animation library for animating bitmap sequences in a Haxe projects. Provides support for common sprite sheet importers.
A useful and flexible sprite sheet library compatible with OpenFL which provides support for common sprite sheet importers.

## Installation

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

haxelib install spritesheet

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

## Usage

Installing Samples
------------------
Spritesheet includes a number of samples which are located in a seperate _spritesheet-samples_ Haxelib which needs to be installed.

haxelib install spritesheet-samples


Listing Samples
---------------
To list all the Spritesheet samples use the following command:

lime create spritesheet


Creating Samples
----------------
If you find a sample you would like to create, you can create it using the "create" command:

lime create spritesheet:Basics

This will create a copy of the sample within the current directory, using the same name as the sample. If you prefer, you can also specify a custom target directory:

lime create spritesheet:Basics SpritesheetTest


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
```as3
var bitmapData = Assets.getBitmapData("some_sprite_sheet.png");
```

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.
```as3
var spritesheet:Spritesheet = BitmapImporter.create( bitmapData, 3, 9, 56, 80);
```

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

Behavior consisting of a name and the cells that should animate
```as3
spritesheet.addBehavior( new BehaviorData("idle", [3, 4, 5], false, 15) );
```

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

AnimatedSprite sheet will be your view and is added to the stage
```as3
var animated:AnimatedSprite = new AnimatedSprite(spritesheet, true)
addChild( animated );
```

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

Tell the sprite what behavior to play
```as3
animated.showBehavior("stand");
```

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.
```as3
private function onEnterFrame(e:Event):Void
{
var time = Lib.getTimer();
var delta = time - lastTime;
animated.update(delta);
lastTime = time;
}
```

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


License
------------

Spritesheet is free, open-source software under the [MIT license](LICENSE.md).

Development Builds
------------

Clone the Spritesheet repository:

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

Tell haxelib where your development copy of Spritesheet is installed:

haxelib dev spritesheet spritesheet

To return to release builds:

haxelib dev spritesheet
Loading