Skip to content

sh-dave/SpriterHaxeEngine

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 it: haxelib install SpriterHaxeEngine

Configure it:

//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);

//you can use a different library to feet your needs. This one use BitmapData.copypixels() and BitmapData.draw()
var lib:BitmapLibrary = new BitmapLibrary('assets/', canvas);

//here is the engine : it will update all your Spriter's entities
engine = new SpriterEngine(Assets.getText('assets/test.scml'), lib, null );
		
//to add and entity
engine.addEntity('entityName', x,  y);

//set the "run" animation of the entity
engine.getEntity('entityName').playAnim('run', myCallback);

//apply the "gun" map of the entity
engine.getEntity('entityName').applyCharacterMap('gun', true);

//update on enter frame
engine.update();

//callback on end anim
function myCallback(s:Spriter, entity:String, anim:String):Void

//var and tag callback
engine.getEntityAt(0).scml.tagCallback = function tagCallback(tag:String):Void{}
engine.getEntityAt(0).scml.varChangeCallback function varCallback(variable:Variable<Dynamic>):Void{}

//points and boxes
var points:Array<SpatialInfo> = engine.getEntityAt(0).getPoints();
var boxes:Array<Quadrilateral> = engine.getEntityAt(0).getBoxes();

Spriter Haxe Engine Features

SCML API

Engine

  • Can be overrided to fit your need
  • simple z-ordering
  • Fixed tick, variable tick or use your own time
  • Pause
  • simple auto removal

Spriter entity

  • character mapping by name
  • change animation easily by name in a Spriter entity
  • callback when animation ended
  • play, stack anim, pause
  • you can display duplicate of spriter entity and manipulate them separatly
  • callback when variable changes
  • callback when tag dispatches
  • Points (usage example : to shot a bullet when gun fire)
  • Boxes (usage example : hitbox)
  • sub entities

Libraries

  • Simple bitmap library (bitmaps handled with addChild, dependency : openfl)
  • BitmapData library (copypixels, dependency : openfl)
  • Tilelayer library (drawTiles using only one tilesheet)(dependency : https://github.com/elsassph/openfl-tilelayer and openfl).
  • DrawTiles library (using many tilesheets)(dependency : https://github.com/elsassph/openfl-tilelayer and openfl).
  • Flixel Library (atlas support or bitmaps handled with addChild, , dependency : flixel) by Zaphod
  • override the AbstractLibrary to provide a new library

Cross-platform

  • flash
  • windows
  • neko
  • android
  • html5

TODO

Examples

Additional information

  • compatible with Spriter r3
  • With Tilelayer library, don't use openfl-bitfive for html5 target.

Known issues

  • [html5] some issues on html5 depending on the backend used and the Library used.
  • Please use the best rendering method according to your target.

About

Engine to use Brashmonkey's Spriter SCML for haxe.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Haxe 100.0%