Commit 2553faf8 authored by limingzhe's avatar limingzhe

fix: debug

parent b712f7bf
...@@ -22,8 +22,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -22,8 +22,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
console.log('this.data: ' + JSON.stringify(this.data)); console.log('this.data: ' + JSON.stringify(this.data));
if (this.data?.skeJsonData?.url) { if (this.data?.skeJsonData?.url) {
this.animBaseUrl = this.data.skeJsonData.ur; // this.animBaseUrl = this.data.skeJsonData.url;
console.log('this.animBaseUrl: ' + this.animBaseUrl ); // console.log('this.animBaseUrl: ' + this.animBaseUrl );
this.data.skeJsonData.url += '?time=' + new Date().getTime() this.data.skeJsonData.url += '?time=' + new Date().getTime()
this.data.texJsonData.url += '?time=' + new Date().getTime() this.data.texJsonData.url += '?time=' + new Date().getTime()
...@@ -665,7 +665,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -665,7 +665,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
changeToMiddleLayer() { changeToMiddleLayer() {
// return; return;
const middleLayer = <any>cc.find("middleLayer"); const middleLayer = <any>cc.find("middleLayer");
...@@ -703,125 +703,127 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -703,125 +703,127 @@ export default class SceneComponent extends MyCocosSceneComponent {
dragonDisplay; dragonDisplay;
animaNode; animaNode;
maxTexture; maxTexture;
atlas;
asset;
setOneAnima(data, cb) { setOneAnima(data, cb) {
console.log(' setOneAnima 1') console.log(' setOneAnima 1')
// let animaNode = new cc.Node(); let animaNode = new cc.Node();
// let dragonDisplay = animaNode.addComponent(dragonBones.ArmatureDisplay); let dragonDisplay = animaNode.addComponent(dragonBones.ArmatureDisplay);
const middleLayer = <any>cc.find("middleLayer"); // const middleLayer = <any>cc.find("middleLayer");
// let myAnimNode = middleLayer?.myAnimNode; // // let myAnimNode = middleLayer?.myAnimNode;
let animaNode = middleLayer?.myAnimNode; // let animaNode = middleLayer?.myAnimNode;
let dragonDisplay; // let dragonDisplay;
if (!animaNode) { // if (!animaNode) {
console.log(' setOneAnima 2') // console.log(' setOneAnima 2')
animaNode = new cc.Node(); // animaNode = new cc.Node();
dragonDisplay = animaNode.addComponent(dragonBones.ArmatureDisplay); // dragonDisplay = animaNode.addComponent(dragonBones.ArmatureDisplay);
const mapMaxScale = this._mapScaleMax; // const mapMaxScale = this._mapScaleMax;
const data = this.data; // const data = this.data;
animaNode.updateScale = (oldS, newS) => { // animaNode.updateScale = (oldS, newS) => {
console.log('in updateScale 1'); // console.log('in updateScale 1');
const cScale = oldS; // const cScale = oldS;
const mScale = newS; // const mScale = newS;
animaNode.scale = cScale / mScale * mapMaxScale; // animaNode.scale = cScale / mScale * mapMaxScale;
if (data.scale) { // if (data.scale) {
animaNode.scale *= data.scale; // animaNode.scale *= data.scale;
console.log('in updateScale 2'); // console.log('in updateScale 2');
} // }
} // }
if (middleLayer) { // if (middleLayer) {
console.log(' setOneAnima 3') // console.log(' setOneAnima 3')
middleLayer.myAnimNode = animaNode; // middleLayer.myAnimNode = animaNode;
} // }
} else { // } else {
console.log(' setOneAnima 4') // console.log(' setOneAnima 4')
dragonDisplay = animaNode.getComponent(dragonBones.ArmatureDisplay); // dragonDisplay = animaNode.getComponent(dragonBones.ArmatureDisplay);
console.log('animaNode.animBaseUr: ' + animaNode.animBaseUr ); // console.log('animaNode.animBaseUr: ' + animaNode.animBaseUr );
if (animaNode.animBaseUrl == this.animBaseUrl) { // if (animaNode.animBaseUrl == this.animBaseUrl) {
animaNode.parent = this.canvas; // animaNode.parent = this.canvas;
animaNode.scale = this._mapScaleMax; // animaNode.scale = this._mapScaleMax;
if (this.data.scale) { // if (this.data.scale) {
animaNode.scale *= this.data.scale; // animaNode.scale *= this.data.scale;
} // }
dragonDisplay.playAnimation(animaNode['animationNames'][0], 1); // dragonDisplay.playAnimation(animaNode['animationNames'][0], 1);
dragonDisplay.timeScale = 0; // dragonDisplay.timeScale = 0;
console.log(' setOneAnima 13') // console.log(' setOneAnima 13')
const frameEventFunc = (e) => { // const frameEventFunc = (e) => {
console.log(' in frameEventFunc ') // console.log(' in frameEventFunc ')
if (this.playTimes > 0) { // if (this.playTimes > 0) {
this.animChangeStep(e['name']); // this.animChangeStep(e['name']);
} // }
}; // };
dragonDisplay.off(dragonBones.EventObject.FRAME_EVENT) // dragonDisplay.off(dragonBones.EventObject.FRAME_EVENT)
dragonDisplay.on(dragonBones.EventObject.FRAME_EVENT, frameEventFunc) // dragonDisplay.on(dragonBones.EventObject.FRAME_EVENT, frameEventFunc)
console.log(' setOneAnima 14') // console.log(' setOneAnima 14')
const compFunc = (e) => { // const compFunc = (e) => {
console.log(' in compFunc ') // console.log(' in compFunc ')
if (this.isLast && this.playTimes > 0) { // if (this.isLast && this.playTimes > 0) {
this.showGoodjob(); // this.showGoodjob();
} else { // } else {
this.animPlayEnd(); // this.animPlayEnd();
} // }
} // }
dragonDisplay.off(dragonBones.EventObject.COMPLETE) // dragonDisplay.off(dragonBones.EventObject.COMPLETE)
dragonDisplay.on(dragonBones.EventObject.COMPLETE, compFunc) // dragonDisplay.on(dragonBones.EventObject.COMPLETE, compFunc)
console.log(' setOneAnima 15') // console.log(' setOneAnima 15')
const touchFunc = (e) => { // const touchFunc = (e) => {
console.log(' in touchFunc ') // console.log(' in touchFunc ')
const pos = e.getLocation(); // const pos = e.getLocation();
const x = pos.x// - e.currentTarget.width / 2; // const x = pos.x// - e.currentTarget.width / 2;
const y = pos.y// - e.currentTarget.height / 2; // const y = pos.y// - e.currentTarget.height / 2;
const newPos = animaNode.convertToNodeSpaceAR(cc.v2(x, y)); // const newPos = animaNode.convertToNodeSpaceAR(cc.v2(x, y));
console.log('X: ', Math.round( newPos.x )); // console.log('X: ', Math.round( newPos.x ));
console.log('Y: ', Math.round( newPos.y )); // console.log('Y: ', Math.round( newPos.y ));
} // }
animaNode.off('touchstart') // animaNode.off('touchstart')
animaNode.on('touchstart', touchFunc) // animaNode.on('touchstart', touchFunc)
console.log(' setOneAnima 16') // console.log(' setOneAnima 16')
this.dragonDisplay = dragonDisplay; // this.dragonDisplay = dragonDisplay;
this.animaNode = animaNode; // this.animaNode = animaNode;
cb && cb(); // cb && cb();
return; // return;
} // }
} // }
animaNode.parent = this.canvas; animaNode.parent = this.canvas;
...@@ -841,8 +843,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -841,8 +843,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
let oldAtlas = dragonDisplay.dragonAtlasAsset
let oldAsset = dragonDisplay.dragonAsset;
// if (myAnimNode) { // if (myAnimNode) {
// const oldDragonDisplay = myAnimNode.getComponent(dragonBones.ArmatureDisplay) // const oldDragonDisplay = myAnimNode.getComponent(dragonBones.ArmatureDisplay)
// oldAtlas = oldDragonDisplay.dragonAtlasAsset; // oldAtlas = oldDragonDisplay.dragonAtlasAsset;
...@@ -867,10 +868,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -867,10 +868,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
console.log(' setOneAnima 8') console.log(' setOneAnima 8')
animaNode.animBaseUrl = this.animBaseUrl; // animaNode.animBaseUrl = this.animBaseUrl;
// console.log(' jumpData == null '); // console.log(' jumpData == null ');
this.delayRelease(oldAtlas, oldAsset) // this.delayRelease(oldAtlas, oldAsset)
// setTimeout(() => { // setTimeout(() => {
...@@ -893,6 +894,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -893,6 +894,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.maxTexture = texture;
const atlas = new dragonBones.DragonBonesAtlasAsset(); const atlas = new dragonBones.DragonBonesAtlasAsset();
atlas.atlasJson = JSON.stringify(atlasJson); atlas.atlasJson = JSON.stringify(atlasJson);
...@@ -903,10 +906,12 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -903,10 +906,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
const asset = new dragonBones.DragonBonesAsset(); const asset = new dragonBones.DragonBonesAsset();
asset.dragonBonesJson = JSON.stringify(dragonBonesJson); asset.dragonBonesJson = JSON.stringify(dragonBonesJson);
this.atlas = atlas;
this.asset = asset;
// console.log(' setOneAnima 10') // console.log(' setOneAnima 10')
animaNode.removeComponent(dragonBones.ArmatureDisplay) // animaNode.removeComponent(dragonBones.ArmatureDisplay)
dragonDisplay = animaNode.addComponent(dragonBones.ArmatureDisplay); // dragonDisplay = animaNode.addComponent(dragonBones.ArmatureDisplay);
console.log('dragonDisplay = ' + typeof(dragonDisplay)); console.log('dragonDisplay = ' + typeof(dragonDisplay));
...@@ -1186,7 +1191,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -1186,7 +1191,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
releaseAssets() { myReleaseAssets() {
// console.log(' in releaseAssets 1'); // console.log(' in releaseAssets 1');
// const maxTexture = this.maxTexture; // const maxTexture = this.maxTexture;
...@@ -1195,12 +1200,81 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -1195,12 +1200,81 @@ export default class SceneComponent extends MyCocosSceneComponent {
// if (cc.assetManager.cacheManager) { // if (cc.assetManager.cacheManager) {
// cc.assetManager.cacheManager.clearCache() // cc.assetManager.cacheManager.clearCache()
// } // }
if (this.dragonDisplay) {
if (this.atlas) {
console.log('this.atlas: ', this.atlas);
this.atlas.decRef();
cc.assetManager.releaseAsset(this.atlas);
this.atlas.destroy();
this.atlas = null;
}
if (this.asset) {
console.log('this.asset: ', this.asset);
this.asset.decRef();
cc.assetManager.releaseAsset(this.asset);
this.asset.destroy();
this.asset = null;
}
// if (!oldAsset) {
// console.log('~~!oldAsset')
// }
// if (!oldAtlas) {
// console.log('~~!oldAtlas')
// }
// if (!this.maxTexture) {
// console.log('~~!this.maxTexture')
// }
// oldAsset.decRef();
// cc.assetManager.releaseAsset(oldAsset);
// oldAsset.destroy();
// oldAtlas.decRef();
// cc.assetManager.releaseAsset(oldAtlas);
// oldAtlas.destroy();
this.animaNode.active = false;
this.animaNode.removeFromParent();
this.maxTexture.decRef();
// this.dragonDisplay = null;
// this.animaNode = null;
// this.maxTexture = null;
}
} }
onDestroy() { onDestroy() {
console.log(' in onDestroy'); // console.log(' 喵喵喵 in onDestroy');
this.changeToMiddleLayer();
this.releaseAssets(); // this.myReleaseAssets();
// const middleLayer = <any>cc.find("middleLayer");
// if (middleLayer) {
// console.log(' 喵喵喵 222 ')
// @ts-ignore
// middleLayer.clearDragonDisplayAssetList();
// }
// this.myReleaseAssets()
// this.changeToMiddleLayer();
// this.releaseAssets();
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment