https://github.com/miltoncandelero/mapsheet
An implementation of spritesheet animation based on OpenFL's Tilemap
https://github.com/miltoncandelero/mapsheet
Last synced: 2 months ago
JSON representation
An implementation of spritesheet animation based on OpenFL's Tilemap
- Host: GitHub
- URL: https://github.com/miltoncandelero/mapsheet
- Owner: miltoncandelero
- License: mit
- Created: 2017-09-01T16:13:54.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-01T18:54:59.000Z (almost 6 years ago)
- Last Synced: 2025-01-19T07:14:07.415Z (4 months ago)
- Language: Haxe
- Size: 6.84 KB
- Stars: 13
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mapsheet
## This library is outdated! Please use [Spritesheet](https://github.com/skylarkstudio/spritesheet) or AnimateCCAtlas (Coming soon tm)
Essentially Mapsheet is an library that turns an spritesheet (or an image atlas) into an animation.
_~~(Mapsheet is my implementation of the [Spritesheet](https://github.com/skylarkstudio/spritesheet) but taking advantage of OpenFL's Tilemap class.)~~_
_([Spritesheet](https://github.com/skylarkstudio/spritesheet) now uses Tilemaps, you should use that)_## Demo
I owe you a demo. <3
## Installation
To install a release build:
haxelib install mapsheetTo include Tilemap in an OpenFL project, add `` to your project.xml.
## Usage
First make sure you have all your imports in place:
```haxe
import mapsheet.Animation;
import mapsheet.Mapsheet;
import mapsheet.data.Behavior;
```Load your spritesheet:
```haxe
var mapsheet = new Mapsheet(Assets.getBitmapData("img/your_spritesheet.png"));
```Quickly slice your spritesheet for equally sized ready to use frames:
```haxe
// rows, columns
mapsheet.slice(7, 8);
```Or you can add the frames manually, make frames different size, offset them!
```haxe
// origX, origY, width, height, offsetX, offsetY
mapsheet.addFrame(0, 0, 100, 100, 50, 50);
mapsheet.addFrame(100, 0, 200, 300, 0, 0);
mapsheet.addFrame(300, 0, 50, 50, 100, 100);
```Write the behavior
```haxe
//name, frames, looping?, frameRate
mapsheet.addBehavior( new Behavior("idle", [3, 4, 5], false, 15) );
```Create your animation
```haxe
var animated:Animation = new Animation(mapsheet);
addChild( animated );
```Tell your animation what behavior to play
```haxe
animated.showBehavior("stand");
```Finally, remember to update the animation and tell it how many time has passed since your last updated it.
```haxe
private function onEnterFrame(e:Event):Void
{
var time = Lib.getTimer();
var delta = time - lastTime;
animated.update(delta);
lastTime = time;
}
```