/openfl-dragonbones

Haxe/OpenFL port of DragonBones api

Primary LanguageHaxeMIT LicenseMIT

openfl-dragonbones

Haxe/OpenFL port of DragonBones api

This is a beta release, tested with DragonBones 2.2 Flash Plugin (dragonbones.effecthub.com/downloads/dragonbones_v2.2.zip)

Currently only supports assets exported as xml + png

Tested targets: Flash, Android, Blackberry, iOS and Windows

Install via haxelib git:

haxelib git dragonbones https://github.com/jalbanesi/openfl-dragonbones.git

Then add to your application.xml:

<haxelib name="dragonbones" />

Usage:

  • Load armatures (if you want a local copy of the Factory use BaseFactory instead of ArmatureManager):
ArmatureManager.instance.parseData(		
		"images/skeleton.xml", 
		"images/texture.xml",
		"images/texture.png" 
	);	
  • Create armature:
  var armature: Armature = ArmatureManager.instance.buildArmature(armatureName);
  • Play animation:
  WorldClock.clock.add(armature);
  armature.animation.gotoAndPlay("run");
  
  // add to the update loop:
  WorldClock.clock.advanceTime(-1);
  • Access individual bones and child armatures:
  var bone: Bone = armature.getBone("aBone");
  
  bone.childArmature.animation.gotoAndPlay("run");
  • Full example:
  // 1 - Create
  var armatureName: String = "Sprites/anArmature");
  var armature: Armature = ArmatureManager.instance.buildArmature(armatureName);
  
  WorldClock.add(armature); // This is necessary to play animations
  parent.addChild(armature.display); // This is necessary to display the armature. parent is a DisplayObjectContainer, like a Sprite
  
  // 2 - Animate
  armature.animation.gotoAndPlay("jump");
  armature.addEventListener(AnimationEvent.COMPLETE, onAnimationComplete); 

  // 3 - Dispose (very important in cpp tartets to prevent memory leaks
  WorldClock.remove(armature);
  parent.removeChild(armature.display);
  armature.dispose();