问题描述:加载远程资源构建一个龙骨,10秒后释放资源,删除node,在过10秒后 重新加载远程资源构建龙骨,发现图片错乱了
问题还原:新建一个场景,添加下面的js代码,运行就可以看到
问题版本:cocos creator v2.3.1
onLoad () {
const that = this;
let npc = null;
// 构建龙骨的函数
const buildNPC = function () {
cc.loader.load({url: 'https://aharesource-bucket.ahaschool.com.cn/game/2020/06/05/5ed9b02f9a78eDWKCUEGs0c.png', type: 'png'}, function (err, pic1) {
cc.loader.load({url: 'https://aharesource-bucket.ahaschool.com.cn/game/2020/06/19/5eec694b3134eWpdeQqNVRx.json', type: 'txt'}, function (err, tex1) {
cc.loader.load({url: 'https://aharesource-bucket.ahaschool.com.cn/game/2020/06/05/5ed9b03861f6dtSC4AQMYuY.json', type: 'txt'}, function (err, ske1) {
npc = new cc.Node;
const armatureDisplay = npc.addComponent(dragonBones.ArmatureDisplay);
const tex = new dragonBones.DragonBonesAtlasAsset;
const ske = new dragonBones.DragonBonesAsset;
tex.texture = pic1;
tex.atlasJson = tex1;
ske.dragonBonesJson = ske1;
armatureDisplay.dragonAsset = ske;
armatureDisplay.dragonAtlasAsset = tex;
armatureDisplay.armatureName = 'Armature';
npc.scale = 0.3;
npc.position = cc.v2(300, 0);
npc.parent = that.node;
});
});
});
}
// 先构建一个龙骨
buildNPC();
// 10秒之后 移除龙骨
this.scheduleOnce(function () {
npc.destroy();
cc.loader.release('https://aharesource-bucket.ahaschool.com.cn/game/2020/06/05/5ed9b02f9a78eDWKCUEGs0c.png');
cc.loader.release('https://aharesource-bucket.ahaschool.com.cn/game/2020/06/19/5eec694b3134eWpdeQqNVRx.json');
cc.loader.release('https://aharesource-bucket.ahaschool.com.cn/game/2020/06/05/5ed9b03861f6dtSC4AQMYuY.json');
}, 10);
// 再过10秒之后 重新构建一个龙骨
this.scheduleOnce(function () {
buildNPC();
}, 20);
},