Solve the error effect of DragonBones when re-enter an auto-released scene.

This commit is contained in:
zhangbin
2017-01-06 18:00:28 +08:00
parent 69aef0634e
commit 337e8346e6
2 changed files with 22 additions and 3 deletions
+20 -2
View File
@@ -341,8 +341,26 @@ dragonBones.ArmatureDisplay = cc.Class({
this._factory.parseTextureAtlasData(this.dragonAtlasAsset.atlasJson, this.dragonAtlasAsset.texture);
} else {
var atlasJsonObj = JSON.parse(this.dragonAtlasAsset.atlasJson);
var texture = cc.textureCache.getTextureForKey(this.dragonAtlasAsset.texture);
this._factory.parseTextureAtlasData(atlasJsonObj, texture);
var atlasName = atlasJsonObj.name;
var existedAtlasData = null;
var atlasDataList = this._factory.getTextureAtlasData(atlasName);
var texturePath = this.dragonAtlasAsset.texture;
if (atlasDataList && atlasDataList.length > 0) {
for (var idx in atlasDataList) {
var data = atlasDataList[idx];
if (data && data.texture && data.texture.url === texturePath) {
existedAtlasData = data;
break;
}
}
}
var texture = cc.textureCache.getTextureForKey(texturePath);
if (existedAtlasData) {
existedAtlasData.texture = texture;
} else {
this._factory.parseTextureAtlasData(atlasJsonObj, texture);
}
}
}
},
+2 -1
View File
@@ -129,7 +129,8 @@ dragonBones.CCSlot = cc.Class({
if (currentTextureData) {
var textureAtlasTexture = currentTextureData.parent.texture;
if (!currentTextureData.texture && textureAtlasTexture) {
if ((!currentTextureData.texture && textureAtlasTexture) ||
(currentDisplayData.texture && textureAtlasTexture && currentTextureData.texture.getTexture() !== textureAtlasTexture)){
// Create and cache texture
var rect = cc.rect(currentTextureData.region.x, currentTextureData.region.y,
currentTextureData.region.width, currentTextureData.region.height);