/**自定义骨架类 */ export default class Armature { public static EventType_Finish:string = 'Animation_Finish'; public static EventType_Frame:string = 'Animation_Frame'; public node:cc.Node; public armatureDisplay:dragonBones.ArmatureDisplay; constructor(path:string,node:cc.Node){ this.node = node; this.armatureDisplay = this.node.addComponent(dragonBones.ArmatureDisplay); this.armatureDisplay.dragonAsset = cc.loader.getRes(path+'/Armature_ske',dragonBones.DragonBonesAsset); this.armatureDisplay.dragonAtlasAsset = cc.loader.getRes(path+'/Armature_tex',dragonBones.DragonBonesAtlasAsset); this.armatureDisplay.armatureName = 'Armature'; this.armatureDisplay.addEventListener(dragonBones.EventObject.COMPLETE,()=>{ this.node.emit(Armature.EventType_Finish,this.getAnimationName()); },this); this.armatureDisplay.addEventListener(dragonBones.EventObject.FRAME_EVENT,(event:any)=>{ this.node.emit(Armature.EventType_Frame,this.getAnimationName(),event.name); }); } public getAnimationName():string{ return this.armatureDisplay.animationName; } public playAnimation(animationName:string,playTimes?:number):void{ this.armatureDisplay.playAnimation(animationName,playTimes==undefined?-1:playTimes); } }