龙骨动画动态替换
从resources文件夹动态加载 龙骨资源进行替换,其他类型资源请参考自定义代码片
.
/**
*
* @param name 需要从resources文件夹加载的名称
* @param type 加载资源的类型
*/
assetLoadRes (name:string,type:any){
return new Promise((resolve, reject)=>{
cc.loader.loadRes(name, type, (err, resAsset) => {
err && reject('未找到资源');
resolve(resAsset);
});
})
}
/**
* 进行龙骨动画替换
*/
async dragonReplace(){
// 龙骨动画资源
// ske 骨骼数据
// tex 骨骼纹理数据
const s = await this.assetLoadRes('Dragon/is_ske',dragonBones.DragonBonesAsset);
const t = await this.assetLoadRes('Dragon/i_tex',dragonBones.DragonBonesAtlasAsset);
if (s && t) {
// 进行龙骨动画替换
}
}