Commit 03da6730 authored by 范雪寒's avatar 范雪寒

feat: 精简

parent 8029fd2d
import { asyncDelay, callMiddleLayerFunction, onHomeworkFinish, playAudio } from "../script/util"; import { asyncDelay, asyncLoadDragonBoneAnime, callMiddleLayerFunction, onHomeworkFinish, playAudio } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent"; import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
...@@ -13,7 +13,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -13,7 +13,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
addPreloadAudio() { addPreloadAudio() {
// TODO 根据自己的配置预加载音频资源 // TODO 根据自己的配置预加载音频资源
this._audioResList.push({ url: (this.data.lrcData && this.data.lrcData.audio_url) || ''}); this._audioResList.push({ url: (this.data.lrcData && this.data.lrcData.audio_url) || '' });
} }
addPreloadAnima() { addPreloadAnima() {
...@@ -21,14 +21,14 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -21,14 +21,14 @@ 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.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()
this.data.texPngData.url += '?time=' + new Date().getTime() this.data.texPngData.url += '?time=' + new Date().getTime()
} }
this._animaResList.push({ url: this.data.skeJsonData.url || '' }); this._animaResList.push({ url: this.data.skeJsonData.url || '' });
this._animaResList.push({ url: this.data.texJsonData.url || ''}); this._animaResList.push({ url: this.data.texJsonData.url || '' });
this._animaResList.push({ url: this.data.texPngData.url || ''}); this._animaResList.push({ url: this.data.texPngData.url || '' });
} }
onLoadEnd() { onLoadEnd() {
...@@ -43,17 +43,17 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -43,17 +43,17 @@ export default class SceneComponent extends MyCocosSceneComponent {
let isDataLoaded = false; let isDataLoaded = false;
let isAnimLoaded = false; let isAnimLoaded = false;
const checkStart = () => { const checkStart = () => {
console.log( ' in checkStart: ', isDataLoaded) console.log(' in checkStart: ', isDataLoaded)
console.log( ' in isAnimLoaded: ', isAnimLoaded) console.log(' in isAnimLoaded: ', isAnimLoaded)
if (isDataLoaded && isAnimLoaded) { if (isDataLoaded && isAnimLoaded) {
window["air"].hideAirClassLoading(); window["air"].hideAirClassLoading();
this.initView(); this.initView();
} }
} }
this.getState(() => { this.getState(() => {
isDataLoaded = true; isDataLoaded = true;
checkStart(); checkStart();
...@@ -87,7 +87,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -87,7 +87,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
callMiddleLayerFunction('PSQS_get_course_info', {}, (data) => { callMiddleLayerFunction('PSQS_get_course_info', {}, (data) => {
console.log(' in getState 2'); console.log(' in getState 2');
this.isFirst = data.first; //this.checkIsFirst(); this.isFirst = data.first; //this.checkIsFirst();
...@@ -144,7 +144,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -144,7 +144,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
return; return;
} }
for (let i=0; i<lyrics.length; i++) { for (let i = 0; i < lyrics.length; i++) {
const data = lyrics[i].data; const data = lyrics[i].data;
if (!data) { if (!data) {
...@@ -155,10 +155,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -155,10 +155,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
let duration = 0; let duration = 0;
if (i != lyrics.length - 1) { if (i != lyrics.length - 1) {
duration = lyrics[i+1].time - lyrics[i].time; duration = lyrics[i + 1].time - lyrics[i].time;
} }
this.textArr.push({data, time, duration}); this.textArr.push({ data, time, duration });
} }
} }
...@@ -179,7 +179,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -179,7 +179,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
initView() { initView() {
console.log( ' in initView') console.log(' in initView')
if (this.jumpData) { if (this.jumpData) {
this.junpAnim(); this.junpAnim();
...@@ -196,7 +196,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -196,7 +196,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
return; return;
} }
...@@ -216,9 +216,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -216,9 +216,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
let disFrame = maxDisFrame; let disFrame = maxDisFrame;
for (let i=1; i<arr.length; i++) { for (let i = 1; i < arr.length; i++) {
const curDis = (arr[i].text - arr[i-1].text) / 2; const curDis = (arr[i].text - arr[i - 1].text) / 2;
if (disFrame > curDis) { if (disFrame > curDis) {
disFrame = curDis; disFrame = curDis;
} }
...@@ -236,7 +236,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -236,7 +236,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.showStartTitleReady(); this.showStartTitleReady();
} }
} }
lightBg; lightBg;
lightLeft; lightLeft;
...@@ -248,7 +248,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -248,7 +248,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
lightBg.scaleY = this.canvas.height / lightBg.height; lightBg.scaleY = this.canvas.height / lightBg.height;
lightBg.opacity = 180; lightBg.opacity = 180;
this.canvas.addChild(lightBg, 10); this.canvas.addChild(lightBg, 10);
const lightLeft = this.getSprNode('light'); const lightLeft = this.getSprNode('light');
lightLeft.anchorY = 0.9; lightLeft.anchorY = 0.9;
...@@ -260,12 +260,12 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -260,12 +260,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
lightLeft.rotation = 45; lightLeft.rotation = 45;
lightLeft.opacity = 0; lightLeft.opacity = 0;
cc.tween(lightLeft) cc.tween(lightLeft)
.to(1, {rotation: -45}, {easing: "cubicOut"}) .to(1, { rotation: -45 }, { easing: "cubicOut" })
.start(); .start();
cc.tween(lightLeft) cc.tween(lightLeft)
.to(0.5, {opacity: 255}) .to(0.5, { opacity: 255 })
.start(); .start();
const lightRight = this.getSprNode('light'); const lightRight = this.getSprNode('light');
lightRight.anchorY = 0.9; lightRight.anchorY = 0.9;
lightRight.x = this.canvas.width / 2; lightRight.x = this.canvas.width / 2;
...@@ -276,10 +276,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -276,10 +276,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
lightRight.rotation = -45; lightRight.rotation = -45;
lightRight.opacity = 0; lightRight.opacity = 0;
cc.tween(lightRight) cc.tween(lightRight)
.to(1, {rotation: 45}, {easing: "cubicOut"}) .to(1, { rotation: 45 }, { easing: "cubicOut" })
.start(); .start();
cc.tween(lightRight) cc.tween(lightRight)
.to(0.5, {opacity: 255}) .to(0.5, { opacity: 255 })
.start(); .start();
...@@ -306,7 +306,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -306,7 +306,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.startAudioEnd(); this.startAudioEnd();
})); }));
}) })
.to(1.5, {y: 0}, {easing: "elasticOut"}) .to(1.5, { y: 0 }, { easing: "elasticOut" })
.start(); .start();
this.title = title this.title = title
...@@ -334,13 +334,13 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -334,13 +334,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
sprNode.opacity = 0; sprNode.opacity = 0;
cc.tween(sprNode) cc.tween(sprNode)
.to(time/10, {opacity: 255}) .to(time / 10, { opacity: 255 })
.start(); .start();
cc.tween(sprNode) cc.tween(sprNode)
.to(0.8 * time, {scale: this._mapScaleMin}, {easing: 'elasticOut'}) .to(0.8 * time, { scale: this._mapScaleMin }, { easing: 'elasticOut' })
.delay(0 * time) .delay(0 * time)
.to(0.2 * time, {opacity: 0}) .to(0.2 * time, { opacity: 0 })
.start(); .start();
} }
...@@ -373,9 +373,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -373,9 +373,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
async hideStartView() { async hideStartView() {
const hideSpr = (sprNode, cb=null) => { const hideSpr = (sprNode, cb = null) => {
cc.tween(sprNode) cc.tween(sprNode)
.to(0.3, {opacity: 0}) .to(0.3, { opacity: 0 })
.call(() => { .call(() => {
sprNode.active = false; sprNode.active = false;
cb && cb(); cb && cb();
...@@ -425,8 +425,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -425,8 +425,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
// this.delayDeleteAnim(); // this.delayDeleteAnim();
callMiddleLayerFunction('PSQS_jump_to_question', {step: id}, null) callMiddleLayerFunction('PSQS_jump_to_question', { step: id }, null)
return; return;
} }
...@@ -463,16 +463,16 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -463,16 +463,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
console.log('PSQS_show_rabbit 1'); console.log('PSQS_show_rabbit 1');
// callMiddleLayerFunction('PSQS_show_rabbit', null, () => { // callMiddleLayerFunction('PSQS_show_rabbit', null, () => {
this.changeToMiddleLayer();
console.log('in changeToMiddleLayer1 '); this.changeToMiddleLayer();
console.log('in changeToMiddleLayer1 ');
// this.delayDeleteAnim(); // this.delayDeleteAnim();
console.log('PSQS_show_rabbit 2')
callMiddleLayerFunction('PSQS_jump_to_question', {step: id}, null) console.log('PSQS_show_rabbit 2')
callMiddleLayerFunction('PSQS_jump_to_question', { step: id }, null)
// }) // })
}) })
} }
...@@ -486,17 +486,17 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -486,17 +486,17 @@ export default class SceneComponent extends MyCocosSceneComponent {
middleLayer.myAnimNode = null; middleLayer.myAnimNode = null;
let dragonDisplay = this.animaNode.getComponent(dragonBones.ArmatureDisplay); let dragonDisplay = this.animaNode.getComponent(dragonBones.ArmatureDisplay);
const oldAtlas = dragonDisplay.dragonAtlasAsset; const oldAtlas = dragonDisplay.dragonAtlasAsset;
const oldAsset = dragonDisplay.dragonAsset; const oldAsset = dragonDisplay.dragonAsset;
this.delayRelease(oldAtlas, oldAsset, this.animaNode); this.delayRelease(oldAtlas, oldAsset, this.animaNode);
console.log(' setOneAnima 101') console.log(' setOneAnima 101')
this.animaNode.removeComponent(dragonBones.ArmatureDisplay) this.animaNode.removeComponent(dragonBones.ArmatureDisplay)
dragonDisplay = this.animaNode.addComponent(dragonBones.ArmatureDisplay); dragonDisplay = this.animaNode.addComponent(dragonBones.ArmatureDisplay);
...@@ -539,7 +539,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -539,7 +539,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
jumpAudio(id) { jumpAudio(id) {
console.log('in jumpAudio id: ', id); console.log('in jumpAudio id: ', id);
const stepData = this.data.stepArr[id-1]; const stepData = this.data.stepArr[id - 1];
console.log('stepData: ', stepData); console.log('stepData: ', stepData);
const time = stepData.text / this.data.frame; const time = stepData.text / this.data.frame;
...@@ -549,13 +549,13 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -549,13 +549,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.audioId = audioId; this.audioId = audioId;
this.audioClip = audioClip; this.audioClip = audioClip;
}); });
} }
continueAnim(id) { continueAnim(id) {
console.log(' in continueAnim') console.log(' in continueAnim')
// this.dragonDisplay.timeScale = 1; // this.dragonDisplay.timeScale = 1;
callMiddleLayerFunction('PSQS_hide_rabbit', null, () => { callMiddleLayerFunction('PSQS_hide_rabbit', null, () => {
...@@ -580,7 +580,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -580,7 +580,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.continueAnim(id); this.continueAnim(id);
this.jumpData = null; this.jumpData = null;
} }
return return
} }
console.log('id: ', id); console.log('id: ', id);
...@@ -620,13 +620,13 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -620,13 +620,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
back.scale = 0.3; back.scale = 0.3;
back.opacity = 0 back.opacity = 0
cc.tween(back) cc.tween(back)
.to(0.9, {scale: this._mapScaleMin, opacity:255}, {easing: 'elasticOut'}) .to(0.9, { scale: this._mapScaleMin, opacity: 255 }, { easing: 'elasticOut' })
.start(); .start();
back.addComponent(cc.Button); back.addComponent(cc.Button);
back.on('click', () => { back.on('click', () => {
console.log('click back') console.log('click back')
callMiddleLayerFunction('PSQS_exit_book', null, () => {}); callMiddleLayerFunction('PSQS_exit_book', null, () => { });
}) })
} }
...@@ -636,16 +636,16 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -636,16 +636,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
// callMiddleLayerFunction('PSQS_show_rabbit', null, () => { // callMiddleLayerFunction('PSQS_show_rabbit', null, () => {
this.changeToMiddleLayer(); this.changeToMiddleLayer();
console.log(' in animPlayEnd 2')
// setTimeout(() => { console.log(' in animPlayEnd 2')
callMiddleLayerFunction('PSQS_play_animate_over', null, () => {})
// }, 100); // setTimeout(() => {
// callMiddleLayerFunction('PSQS_play_animate_over', this.animaNode, () => {}) callMiddleLayerFunction('PSQS_play_animate_over', null, () => { })
// }, 100);
// callMiddleLayerFunction('PSQS_play_animate_over', this.animaNode, () => {})
// }) // })
} }
changeToMiddleLayer() { changeToMiddleLayer() {
...@@ -667,28 +667,86 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -667,28 +667,86 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.animaNode.scale = cScale / mScale * this._mapScaleMax; this.animaNode.scale = cScale / mScale * this._mapScaleMax;
if (this.data.scale) { if (this.data.scale) {
this.animaNode.scale *= this.data.scale; this.animaNode.scale *= this.data.scale;
} }
this.dragonDisplay.dragonAtlasAsset.addRef(); this.dragonDisplay.dragonAtlasAsset.addRef();
this.dragonDisplay.dragonAsset.addRef(); this.dragonDisplay.dragonAsset.addRef();
// setTimeout(() => { // setTimeout(() => {
console.log('in changeToMiddleLayer 2 '); console.log('in changeToMiddleLayer 2 ');
this.animaNode.parent = middleLayer; this.animaNode.parent = middleLayer;
// }, 50); // }, 50);
} }
} }
async setOneAnima1(data, cb) {
if (!data.texPngData) {
return
}
asyncLoadDragonBoneAnime(this.canvas, data);
const animaNode = this.canvas.animaNode;
animaNode.scale = this._mapScaleMax;
if (this.data.scale) {
animaNode.scale *= this.data.scale;
}
const dragonDisplay = animaNode.getComponent(dragonBones.ArmatureDisplay);
dragonDisplay.armatureName = dragonDisplay.getArmatureNames()[0];
const animationName = dragonDisplay.getAnimationNames()[0];
dragonDisplay.playAnimation(animationName, 1);
dragonDisplay.timeScale = 0;
dragonDisplay.off(dragonBones.EventObject.FRAME_EVENT)
dragonDisplay.on(dragonBones.EventObject.FRAME_EVENT, (event) => {
console.log(' in frameEventFunc ')
if (this.playTimes > 0) {
this.animChangeStep(event.name);
}
})
dragonDisplay.off(dragonBones.EventObject.COMPLETE)
dragonDisplay.on(dragonBones.EventObject.COMPLETE, () => {
console.log(' in compFunc ')
if (this.isLast && this.playTimes > 0) {
this.showGoodjob();
} else {
this.animPlayEnd();
}
})
animaNode.off('touchstart')
animaNode.on('touchstart', (e) => {
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));
});
this.dragonDisplay = dragonDisplay;
this.animaNode = animaNode;
cb && cb();
}
dragonDisplay; dragonDisplay;
animaNode; animaNode;
maxTexture; maxTexture;
setOneAnima(data, cb) { setOneAnima(data, cb) {
this.setOneAnima1(data, cb);
return;
console.log(' setOneAnima 1') console.log(' setOneAnima 1')
...@@ -724,7 +782,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -724,7 +782,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
// animaNode.scale *= data.scale; // animaNode.scale *= data.scale;
// console.log('in updateScale 2'); // console.log('in updateScale 2');
// } // }
// } // }
// if (middleLayer) { // if (middleLayer) {
...@@ -741,18 +799,18 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -741,18 +799,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
if (!data.texPngData) { if (!data.texPngData) {
return return
} }
console.log(' setOneAnima 5') console.log(' setOneAnima 5')
const image = data.texPngData.url; //"http://staging-teach.cdn.ireadabc.com/5a0c5af3e952acd0ac83a6e5c6f03ff1.png"; const image = data.texPngData.url; //"http://staging-teach.cdn.ireadabc.com/5a0c5af3e952acd0ac83a6e5c6f03ff1.png";
const ske = data.skeJsonData.url; //"http://staging-teach.cdn.ireadabc.com/bd825dcceea298d1146be8067ae3d17f.json"; const ske = data.skeJsonData.url; //"http://staging-teach.cdn.ireadabc.com/bd825dcceea298d1146be8067ae3d17f.json";
const atlas = data.texJsonData.url; //"http://staging-teach.cdn.ireadabc.com/246f8991b729fa3e5a7f4802de828efa.json"; const atlas = data.texJsonData.url; //"http://staging-teach.cdn.ireadabc.com/246f8991b729fa3e5a7f4802de828efa.json";
// let oldAtlas; // let oldAtlas;
// let oldAsset; // let oldAsset;
// if (myAnimNode) { // if (myAnimNode) {
...@@ -760,22 +818,22 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -760,22 +818,22 @@ export default class SceneComponent extends MyCocosSceneComponent {
// oldAtlas = oldDragonDisplay.dragonAtlasAsset; // oldAtlas = oldDragonDisplay.dragonAtlasAsset;
// oldAsset = oldDragonDisplay.dragonAsset; // oldAsset = oldDragonDisplay.dragonAsset;
// } // }
cc.assetManager.loadRemote(image, (error, texture) => { cc.assetManager.loadRemote(image, (error, texture) => {
console.log(' setOneAnima 6') console.log(' setOneAnima 6')
// cc.loader.load({url: atlas, type: 'txt'}, (error, atlasJson) => { // cc.loader.load({url: atlas, type: 'txt'}, (error, atlasJson) => {
cc.assetManager.loadAny({ url: atlas, reload: true }, (error, atlasJson) => { cc.assetManager.loadAny({ url: atlas, reload: true }, (error, atlasJson) => {
console.log(' setOneAnima 7') console.log(' setOneAnima 7')
// cc.loader.load({url: ske, type: 'txt'}, (error, dragonBonesJson) => { // cc.loader.load({url: ske, type: 'txt'}, (error, dragonBonesJson) => {
cc.assetManager.loadAny({ url: ske, reload: true }, (error, dragonBonesJson) => { cc.assetManager.loadAny({ url: ske, reload: true }, (error, dragonBonesJson) => {
console.log(' setOneAnima 8') console.log(' setOneAnima 8')
...@@ -805,9 +863,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -805,9 +863,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
// this.maxTexture = texture; // this.maxTexture = texture;
// const atlas = new dragonBones.DragonBonesAtlasAsset(); // const atlas = new dragonBones.DragonBonesAtlasAsset();
// atlas.atlasJson = atlasJson; // atlas.atlasJson = atlasJson;
// atlas.texture = texture; // atlas.texture = texture;
const atlas = new dragonBones.DragonBonesAtlasAsset(); const atlas = new dragonBones.DragonBonesAtlasAsset();
atlas.atlasJson = JSON.stringify(atlasJson); atlas.atlasJson = JSON.stringify(atlasJson);
...@@ -818,54 +876,54 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -818,54 +876,54 @@ 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);
// 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));
dragonDisplay.dragonAtlasAsset = atlas; dragonDisplay.dragonAtlasAsset = atlas;
console.log('汪汪汪 1') console.log('汪汪汪 1')
dragonDisplay.dragonAsset = asset; dragonDisplay.dragonAsset = asset;
console.log('汪汪汪 2') console.log('汪汪汪 2')
console.log('type: ' + typeof(asset.dragonBonesJson)); console.log('type: ' + typeof (asset.dragonBonesJson));
let json = JSON.parse(asset.dragonBonesJson); let json = JSON.parse(asset.dragonBonesJson);
console.log('json: ', json); console.log('json: ', json);
let armatures = json["armature"]; let armatures = json["armature"];
console.log('armatures: ', armatures); console.log('armatures: ', armatures);
let armatureNames = []; let armatureNames = [];
for (let i = 0; i < armatures.length; i++) { for (let i = 0; i < armatures.length; i++) {
armatureNames.push(armatures[i].name); armatureNames.push(armatures[i].name);
} }
console.log('armatureNames: ', armatureNames); console.log('armatureNames: ', armatureNames);
console.log(' setOneAnima 11') console.log(' setOneAnima 11')
if (armatureNames.length > 0) { if (armatureNames.length > 0) {
let defaultArmatureName = armatureNames[0]; let defaultArmatureName = armatureNames[0];
dragonDisplay.armatureName = defaultArmatureName; dragonDisplay.armatureName = defaultArmatureName;
// let animationNames = dragonDisplay.getAnimationNames(defaultArmatureName); // let animationNames = dragonDisplay.getAnimationNames(defaultArmatureName);
let defaultArmature = armatures[0]; let defaultArmature = armatures[0];
let animations = defaultArmature.animation; let animations = defaultArmature.animation;
let animationNames = []; let animationNames = [];
for (let i = 0; i < animations.length; i++) { for (let i = 0; i < animations.length; i++) {
animationNames.push(animations[i].name); animationNames.push(animations[i].name);
} }
animaNode['animationNames'] = animationNames; animaNode['animationNames'] = animationNames;
} }
console.log(' setOneAnima 12') console.log(' setOneAnima 12')
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.timeScale = 50; // dragonDisplay.timeScale = 50;
...@@ -875,7 +933,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -875,7 +933,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
// animaNode.parent = middleLayer; // animaNode.parent = middleLayer;
// // dragonDisplay.dragonAtlasAsset.decRef(); // // dragonDisplay.dragonAtlasAsset.decRef();
// // dragonDisplay.destroy(); // // dragonDisplay.destroy();
...@@ -885,10 +943,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -885,10 +943,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
// setTimeout(() => { // setTimeout(() => {
// callMiddleLayerFunction('PSQS_play_animate_over', null, () => {}) // callMiddleLayerFunction('PSQS_play_animate_over', null, () => {})
// }, 1000); // }, 1000);
// }, 10000); // }, 10000);
// return ; // return ;
...@@ -921,7 +979,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -921,7 +979,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
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) => {
...@@ -933,8 +991,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -933,8 +991,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
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)
...@@ -947,19 +1005,19 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -947,19 +1005,19 @@ export default class SceneComponent extends MyCocosSceneComponent {
cb && cb(); cb && cb();
// console.log("animaNode: ", animaNode); // console.log("animaNode: ", animaNode);
}); });
}); });
}); });
} }
delayRelease(oldAtlas, oldAsset, delteItem=null) { delayRelease(oldAtlas, oldAsset, delteItem = null) {
setTimeout(() => { setTimeout(() => {
if (oldAtlas) { if (oldAtlas) {
console.log(' in aaaa 1') console.log(' in aaaa 1')
if (oldAtlas.texture) { if (oldAtlas.texture) {
...@@ -1008,7 +1066,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -1008,7 +1066,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
getCurTextObj() { getCurTextObj() {
const data = this.textArr[this.textArrIndex]; const data = this.textArr[this.textArrIndex];
if (data) { if (data) {
this.textArrIndex ++; this.textArrIndex++;
} }
return data; return data;
} }
...@@ -1036,30 +1094,30 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -1036,30 +1094,30 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.textLabel.curTween.stop(); this.textLabel.curTween.stop();
} }
this.textLabel.node.opacity = 0; this.textLabel.node.opacity = 0;
this.textLabel.string = `<outline color=white width=4>${textObj.data}</outline>` this.textLabel.string = `<outline color=white width=4>${textObj.data}</outline>`
if (textObj.duration ) { if (textObj.duration) {
this.textLabel.curTween = cc.tween(this.textLabel.node) this.textLabel.curTween = cc.tween(this.textLabel.node)
.to(0.2, {opacity: 255}, {easing: 'sineOut'}) .to(0.2, { opacity: 255 }, { easing: 'sineOut' })
.delay(textObj.duration ) .delay(textObj.duration)
.call(() => { .call(() => {
this.curTextObj = null; this.curTextObj = null;
}) })
.to(0.1, {opacity: 0}) .to(0.1, { opacity: 0 })
.start(); .start();
} else { } else {
this.textLabel.curTween = cc.tween(this.textLabel.node) this.textLabel.curTween = cc.tween(this.textLabel.node)
.to(0.2, {opacity: 255}, {easing: 'sineOut'}) .to(0.2, { opacity: 255 }, { easing: 'sineOut' })
.start(); .start();
} }
} }
getTextLabel() { getTextLabel() {
const richTextNode = new cc.Node(); const richTextNode = new cc.Node();
richTextNode.y = -this.canvas.height / 2 + 20 * this._mapScaleMin ; richTextNode.y = -this.canvas.height / 2 + 20 * this._mapScaleMin;
richTextNode.opacity = 0; richTextNode.opacity = 0;
richTextNode.anchorY = 0; richTextNode.anchorY = 0;
richTextNode.scale = this._mapScaleMin; richTextNode.scale = this._mapScaleMin;
...@@ -1091,7 +1149,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -1091,7 +1149,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
update (dt) { update(dt) {
this.checkShowText(); this.checkShowText();
} }
...@@ -1111,7 +1169,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -1111,7 +1169,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
// cc.assetManager.cacheManager.clearCache() // cc.assetManager.cacheManager.clearCache()
// } // }
} }
onDestroy() { onDestroy() {
console.log(' in onDestroy'); console.log(' in onDestroy');
this.releaseAssets(); this.releaseAssets();
......
...@@ -238,7 +238,7 @@ export async function asyncLoadDragonBoneAnime(node, { skeJsonData: { url: skeJs ...@@ -238,7 +238,7 @@ export async function asyncLoadDragonBoneAnime(node, { skeJsonData: { url: skeJs
Promise.all([loadTexture, loadTexJsonData, loadSkeJsonData]).then(([texture, atlasJson, dragonBonesJson]) => { Promise.all([loadTexture, loadTexJsonData, loadSkeJsonData]).then(([texture, atlasJson, dragonBonesJson]) => {
const atlas = new dragonBones.DragonBonesAtlasAsset(); const atlas = new dragonBones.DragonBonesAtlasAsset();
atlas.atlasJson = JSON.stringify(atlasJson); atlas.atlasJson = JSON.stringify(atlasJson);
atlas.texture = texture; atlas.texture = <any>texture;
const asset = new dragonBones.DragonBonesAsset(); const asset = new dragonBones.DragonBonesAsset();
asset.dragonBonesJson = JSON.stringify(dragonBonesJson); asset.dragonBonesJson = JSON.stringify(dragonBonesJson);
...@@ -246,7 +246,7 @@ export async function asyncLoadDragonBoneAnime(node, { skeJsonData: { url: skeJs ...@@ -246,7 +246,7 @@ export async function asyncLoadDragonBoneAnime(node, { skeJsonData: { url: skeJs
dragonDisplay.dragonAtlasAsset = atlas; dragonDisplay.dragonAtlasAsset = atlas;
dragonDisplay.dragonAsset = asset; dragonDisplay.dragonAsset = asset;
let armatureNames = dragonBonesJson.armature.map(data => data.name); let armatureNames = (<any>dragonBonesJson).armature.map(data => data.name);
if (armatureNames.length > 0) { if (armatureNames.length > 0) {
dragonDisplay.armatureName = armatureNames[0]; dragonDisplay.armatureName = armatureNames[0];
......
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