Coder Social home page Coder Social logo

spriterhaxeengine's Introduction

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)

Libraries

  • Simple bitmap library (bitmaps handled with addChild)
  • BitmapData library (copypixels)
  • Tilelayer library (drawTiles)(dependency : https://github.com/matthewswallace/openfl-tilelayer).
  • Flixel Library (atlas support or bitmaps handled with addChild)
  • override the AbstractLibrary to provide a new library

Cross-platform

  • flash
  • windows
  • neko
  • android
  • html5

TODO

  • add tilesheet stage 3d support : https://github.com/as3boyan/TilesheetStage3D/
  • add ash and haxepunk support
  • Optimized engine : draw call only when needed. So "instant" keys are not updated between keys.
  • animation callback optimization
  • check Garbage collector
  • binary scml

Examples

Additional information

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

Known issues

  • interpolation are not enough smooth at the end of a looping animation (need to check if the interpolation with the first frame is ok)
  • [html5] some issues on html5 depending on the backend used and the Library used.
  • [neko] if you have trouble with TileLayerLibrary, please update tilelayer with : matthewswallace/openfl-tilelayer#5

spriterhaxeengine's People

Contributors

beeblerox avatar loudoweb avatar sruloart avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.