//加载动画文件
let skeletonData = RES.getRes(skeleton_json); //"skeleton_json"
let textureData = RES.getRes(texture_json); //"texture_json"
let texture = RES.getRes(texture_png);//"texture_png"
//一般项目中创建一个dragonbones工厂就可以了
var dragonbonesFactory: dragonBones.EgretFactory = new dragonBones.EgretFactory();
//动画数据加入到工厂中
dragonbonesFactory.addDragonBonesData(dragonBones.DataParser.parseDragonBonesData(skeletonData));
dragonbonesFactory.addTextureAtlas(new dragonBones.EgretTextureAtlas(texture, textureData));
//从工厂中取出动画 拷贝一个动画数据
//----aniname为 skeleton_json文件中 armature ---> name 字段值
var armature: dragonBones.Armature = dragonbonesFactory.buildArmature("001");
//获取动画的显示加入到绘制的父类容器中
this.addChild(armature.getDisplay());
//play 接受两个参数 动画名字 及播放次数 0 : 代表无限播放 1 ~ N : 代表播放1~N次
armature.animation.play("atk", 2); //atk0
//设置动画显示位置
armature.display.x = 300;
armature.display.y = 500;
//调节动画速度
armature.animation.timeScale = 0.5;
//调节动作速度
//armature.play("walk").setTimeScale(0.5);
//开启大时钟这步很关键
//DragonBones动画库中有个WorldClock类,提供了世界时钟的功能。一般情况下,
//我们推荐开发者将所有创建的骨架都加到一个世界时钟中去,然后在引擎的Ticker中注册一个回调函数调用世界时钟的advanceTime方法,
//这样所有加到这个世界时钟的骨架就都能够正确的运行了
dragonBones.WorldClock.clock.add(armature);
//----这里从工厂中再取出一个动画
var armature1: dragonBones.Armature = dragonbonesFactory.buildArmature(aniname);
this.addChild(armature1.getDisplay());
armature1.animation.play("atk0", 0); //atk0
armature1.display.x = 600;
armature1.display.y = 500;
//开启大时钟这步很关键
dragonBones.WorldClock.clock.add(armature1);
egret.Ticker.getInstance().register(function(advancedTime){
dragonBones.WorldClock.clock.advanceTime(0.01); //advancedTime/1000
},this);