openfl / dragonbones

Runtime support for DragonBones skeletal animation
http://www.dragonbones.com
Other
41 stars 14 forks source link

Flixel Factory and OpenFL Legacy (3.6.1) compatibility. #3

Closed troyedwardsjr closed 6 years ago

troyedwardsjr commented 7 years ago

Added a flixel factory backend and #if (openfl > 3.6.1) compiler conditionals.

Compiler conditionals are not fully complete but should still work on OpenFL 6 as they're just Arrays instead of Vectors. If anyone wants to help with that, you can commit to this pull request. But I thought I'd get feedback from Joshua Granick about how we should proceed from here to so I made this PR now.

However, it should be fully functional on OpenFL 3.6.1 and OpenFL 6.

DragonBoy Gif.

Basic flixel demo/test under samples/HelloDragonbones. The JSON files were exported using the latest DragonBones (5.3).

Make sure to build using the webgl haxe define IE haxelib run lime build html5 -Dwebgl in order to be able to render anti-aliasing and any animations that require meshes.

Some notes:

  1. I know you wanted to keep it as close as possible to the original AS3 API, but I had to change the animation field to animations because it conflicts with the animation field on FlxSprite and FlxStrip. Other suggestions are welcome.

  2. On BaseObject I had to create a ClassMap class under the /util folder in order to give it similar functionality to an OpenFL 6 Dictionary to accept Class types.

  3. The OpenFL event dispatcher can't really be used with specific FlxSprites because I believe it would require DisplayObjects being added to the stage, which is both tricky because you can't override a FlxGroup.add from a FlxSprite in order to also add a parallel DisplayObject to the flash display list (which HaxeFlixel doesn't use) at the same time and could result in pretty poor performance to add a DisplayObject for every FlxSprite which must then also be eventually be removed from the display list along with the FlxSprite. So I just used a global FlxG.stage for OpenFL events instead, for those that want to use them.

Feel free to add to this PR. Once it's merged into the main repo I can make a pull request add a demo to the flixel-demos repo and possibly make it a dependency of flixel-addons similar to spinehaxe, rather than put my fork on haxelib.