Commit 2553faf8 authored by limingzhe's avatar limingzhe

fix: debug

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