Home

Awesome

SpriterHaxeEngine

The point of this project is to offer a Brashmonkey's Spriter SCML renderer compatible with Haxe 3 and openfl. Base code of SCML definitions from http://www.brashmonkey.com/ScmlDocs/ScmlReference.html

Inspired by

Install: haxelib install SpriterHaxeEngine

Choose your drawing library:

/**
* Example with the TilemapLibrary which uses openfl-atlas (haxelib install openfl-atlas)
*/
//set the root canvas where to add all the animations
var spriterRoot:Sprite = new Sprite();
addChild(spriterRoot);
//get an atlas
var tileset:TilesetEx = new SpriterTileset(Assets.getBitmapData('assets/atlas.png'), Assets.getText('assets/atlas.xml'));
//choose a rendering method.
var lib = new TilemapLibrary([tileset], spriterRoot, stage.stageWidth, stage.stageHeight);

/**
* Example with the BitmapLibrary which uses BitmapData.copypixels() and BitmapData.draw()
*/
//set the root canvas where to add all the animations
var canvas:BitmapData = new BitmapData(800, 480);
var spriterRoot:Bitmap = new Bitmap(canvas, PixelSnapping.AUTO, true);
addChild(spriterRoot);
//choose a rendering method.
var lib:BitmapLibrary = new BitmapLibrary('assets/', canvas);

/**
* Other libraries exist to use Spriter with flixel and other rendering method!
*/

Instantiate the engine:

//Create the engine.
//you can specify a default scml or you can specify it later in addSpriter()
engine = new SpriterEngine(Assets.getText('assets/test.scml'), lib );
		
//Add a Spriter in the engine. A Spriter contains all data from the scml (all entities, animations, boxes, tags...)
//By default, it will play the first animation of the first entity of your scml
engine.addSpriter('uniqueId', x,  y);

//Set the "run" animation of the entity
engine.getSpriter('uniqueId').playAnim('run', myCallback);

//Apply the "gun" map of the entity
engine.getSpriter('uniqueId').applyCharacterMap('gun', true);

//Update on enter frame to draw all Spriters on screen
engine.update();

//Callback on end anim
function myCallback(s:Spriter):Void

//callback
engine.getSpriterAt(0).onVarChanged = function varCallback(name:String, value:Dynamic):Void{}
engine.getSpriterAt(0).onEvent = function eventCallback(name:String):Void{}
engine.getSpriterAt(0).onSound = function soundCallback(name:String):Void{}

//current points and boxes
var points:Array<SpatialInfo> = engine.getSpriterAt(0).points;
var boxes:Array<Quadrilateral> = engine.getSpriterAt(0).boxes;

//current tags
var tags:Array<String> = engine.getSpriterAt(0).tags;

//current variables values
var value:Dynamic = engine.getSpriterAt(0).getVariable('myVar');


//stack anims
engine.getSpriter('uniqueId').playAnimsStackFromEntity("entityName", ["anim1","anim2"], myCallback).

Spriter Haxe Engine Features

SCML API

Engine

Spriter entity

Libraries

Other features

Cross-platform

TODO

WIKI

The wiki provides more details on features and how it works.

Examples

Additional information

Known issues