DBSprite: DragonBones support for Starling Builder

Starling Builder supports loading DragonBones animation through a custom component called DBSprite. The following document explains how to setup both editor and game.

For editor

You can check out dragonbones_test.json in the latest demo workspace, which is already set up to work

For game

There are 2 dependencies you need to inject to DragonBones in order to make it work: StarlingFactory and WorldClock. Thanks to the IAssetMediator.getCustomData interface, you can inject basically everything you want into a custom component that takes a IAssetMediator as a constructor parameter.

In this case, this is what you need to do to implement the method

override public function getCustomData(type:String, name:String):Object
{
    switch (type)
    {
        case DBSprite.STARLING_FACTORY:
            return _starlingFactory;
        case DBSprite.WORLD_CLOCK:
            return _worldClock;
        default:
            return null;
    }
}

It’s up to you how to create and manage _starlingFactory and _worldClock in your game. As long as you return the right dependencies from IAssetMediator.getCustomData, it will work.