Cocos Creator TS加载龙骨
Posted LANGZI7758521
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cocos Creator TS加载龙骨相关的知识,希望对你有一定的参考价值。
const {ccclass, property} = cc._decorator;
@ccclass
export default class TSdragonbones extends cc.Component {
@property(dragonBones.ArmatureDisplay)
dragonBone:dragonBones.ArmatureDisplay = null;
dynamicCreate () {
if (this.dragonBone.dragonAtlasAsset) {
return;
}
cc.resources.load('dragonBones/NewDragonTest', dragonBones.DragonBonesAsset, (err, res:dragonBones.DragonBonesAsset) => {
if (err) cc.error(err);
this.dragonBone.dragonAsset = res; //设置骨骼数据
cc.resources.load('dragonBones/texture', dragonBones.DragonBonesAtlasAsset, this.onComplete.bind(this));
});
}
onComplete (err, res) {
if (err) cc.error(err);
this.dragonBone.dragonAtlasAsset = res;//设置骨骼数据所需Atlas
this.dragonBone.armatureName = 'armatureName';//设置皮肤
this.dragonBone.playAnimation('stand', 0);//播放动画
}
}
以上是关于Cocos Creator TS加载龙骨的主要内容,如果未能解决你的问题,请参考以下文章
Cocos Creator 龙骨DragonBones(导出骨骼/使用骨骼/局部换装/全局换装)