Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/AustinEast/heaps-aseprite
An Aseprite File Parser for Heaps
https://github.com/AustinEast/heaps-aseprite
aseprite haxe heaps
Last synced: 3 months ago
JSON representation
An Aseprite File Parser for Heaps
- Host: GitHub
- URL: https://github.com/AustinEast/heaps-aseprite
- Owner: AustinEast
- License: mit
- Created: 2020-10-18T03:39:23.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-01-26T21:13:13.000Z (about 1 year ago)
- Last Synced: 2024-08-02T14:08:02.005Z (6 months ago)
- Topics: aseprite, haxe, heaps
- Language: Haxe
- Homepage: https://lib.haxe.org/p/heaps-aseprite/
- Size: 76.2 KB
- Stars: 28
- Watchers: 2
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# heaps-aseprite
Load and render sprites and animations in Aseprite format. Based on the [ase](https://github.com/miriti/ase) and [openfl-aseprite](https://github.com/miriti/openfl-aseprite) libraries. Sample Aseprite files all borrowed from `openfl-aseprite`.## Features
* Hooks into the Heaps Engine's resource management to automatically handle any `.aseprite` or `.ase` file
* Optimizes runtime performance by parsing Aseprite files during compilation (generating `.png` and `.asedata` files)
* Supports all Color Modes, Animation Tags, Layers, and Slices (including 9-Slices!)
* Includes the `AseAnim` Class to easily render Animations (based on the Heaps Engine's `Anim` Class)
* Supports Live Resource Updating
* Gets Type-safe references to an Aseprite file's Tags and Slices (thanks @deepnight!)## Getting Started
heaps-aseprite requires [Haxe 4](https://haxe.org/download/) and the [Heaps Engine](https://heaps.io) to run.
Install the library from haxelib:
```
haxelib install heaps-aseprite
```
Alternatively the dev version of the library can be installed from github:
```
haxelib git heaps-aseprite https://github.com/AustinEast/heaps-aseprite.git
```Install heaps-aseprite's dependency, [ase](https://github.com/miriti/ase).
```
haxelib install ase
```Then include the library in your project's `.hxml`:
```hxml
-lib heaps-aseprite
```## Example
```haxe
// Get the whole sprite as a Tile
var spr1 = new Bitmap(Res.single_frame_sprite.toAseprite().toTile(), s2d);// Alternatively get the sprite directly as an Image
var image = new Bitmap(Res.single_frame_sprite.toImage().toTile(), s2d);// Get an animation from the sprite's tag
var spr2 = new AseAnim(Res.animated_sprite.toAseprite().getTag('walk'), s2d);
spr2.loop = true;// Override the direction of a tagged animation
var spr3 = new AseAnim(Res.animated_sprite.toAseprite().getTag('walk', AnimationDirection.REVERSE), s2d);
spr3.loop = true;// Get an animation based on tag and slice
var spr4 = new AseAnim(Res.animated_sprite.toAseprite().getTag('walk', -1, 'Head'), s2d);
spr4.loop = true;// Get a single frame from a slice
var slice = new Bitmap(Res.slices.toAseprite().getSlice('Slice 1').tile, s2d);// Get all frames from a slice
var slice2 = new AseAnim(Res.slices.toAseprite().getSlices('Slice 1'), s2d);
slice2.loop = true;// Get a 9-Slice ScaleGrid from a slice
var nineSlice = Res.nine_slices.toAseprite().toScaleGrid('9-Slices', 0, s2d);// Live Resource Updatng
var animation = new AseAnim(Res.animated_sprite.toAseprite().getTag('walk'), s2d);
animation.loop = true;
Res.animated_sprite.watch(() -> {
// Make sure to call the default `watch()` callback!
Res.animated_sprite.updateData();// Replay the animation to get the updated frames
animation.play(Res.animated_sprite.toAseprite().getTag('walk'));
});// Want type-safe Tags and Slices? Use the `Dictionary` class to get typed references from an Aseprite resource
var typeSafeTags = Dictionary.getTags(Res.animated_sprite);
new AseAnim(Res.animated_sprite.toAseprite().getTag(typeSafeTags.walk), flow);var typeSafeSlices = Dictionary.getSlices(Res.slices);
new Bitmap(Res.slices.toAseprite().getSlice(typeSafeSlices.Slice_1).tile, flow);
```## Roadmap
* Document codebase (public fields and methods)