private addAmin(data, puzzleNode: Node) {
let animParam = JSON.parse(data.animParam);
assetManager.loadRemote(data.animPlist, (err: Error, asset: Asset) => {
if (!err && asset) {
RemoteSpriteMgr.getTexture(data.animAtlas).then((texture: Texture2D) => {
this.createAnimationClip(texture,asset);
if (!!animParam.speed) {
this.animationClip.speed = animParam.speed;
} else {
this.animationClip.speed = 0.3;
}
//添加动画
let animNode = puzzleNode.getChildByName('animNode');
let scale = new Vec3(1, 1, 1);
if (!!animParam.size) {
let size = 1 / animParam.size;
scale = new Vec3(size, size, 1);
}
animNode.setScale(scale);
let animation = animNode.getComponent(Animation);
if (!!!animation) {
animation = animNode.addComponent(Animation);
animNode.addComponent(Sprite);
}
animation.addClip(this.animationClip, 'animationClip');
//播放动画
animation.play('animationClip');
});
}
});
}