Commit a64a96d6 authored by Tt's avatar Tt

修改完成

parent a41a6d6f
...@@ -2132,7 +2132,7 @@ ...@@ -2132,7 +2132,7 @@
"__id__": 45 "__id__": 45
} }
], ],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 48 "__id__": 48
...@@ -11723,7 +11723,7 @@ ...@@ -11723,7 +11723,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "xiaodi", "_name": "layout_xiaodi",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 2 "__id__": 2
...@@ -11830,15 +11830,15 @@ ...@@ -11830,15 +11830,15 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
495.934, 515.859,
-172.815, -196.362,
0, 0,
0, 0,
0, 0,
0, 0,
1, 1,
0.35, 0.3,
0.35, 0.3,
0.4 0.4
] ]
}, },
...@@ -11937,7 +11937,7 @@ ...@@ -11937,7 +11937,7 @@
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
504.797, 504.797,
95.957, 41.045,
0, 0,
0, 0,
0, 0,
...@@ -11986,7 +11986,7 @@ ...@@ -11986,7 +11986,7 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 97.87, "width": 0,
"height": 50.4 "height": 50.4
}, },
"_anchorPoint": { "_anchorPoint": {
......
...@@ -2,6 +2,7 @@ import { asyncDelay, onHomeworkFinish, RandomInt } from "../script/util"; ...@@ -2,6 +2,7 @@ import { asyncDelay, onHomeworkFinish, RandomInt } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent"; import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
import Game from "./Game"; import Game from "./Game";
import pg from "./pg"; import pg from "./pg";
import dg_xiaodi from "./xiaodi";
enum touchState { enum touchState {
NORMAL, NORMAL,
...@@ -64,6 +65,11 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -64,6 +65,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考 // TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this.initData(); this.initData();
this.initView(); this.initView();
this.startShowXiaodi().then(() => {
this.endShowXiaodi();
this.showQuestion();
this.showGame();
})
} }
_cantouch = null; _cantouch = null;
...@@ -75,14 +81,29 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -75,14 +81,29 @@ export default class SceneComponent extends MyCocosSceneComponent {
// this._colors = ["#f87b8e", "#fdb652", "#4acfe0", "#30ff6d", "#848cff"]; // this._colors = ["#f87b8e", "#fdb652", "#4acfe0", "#30ff6d", "#848cff"];
} }
startShowXiaodi() {
return new Promise((resolve, reject) => {
if (!this.data.npcAudio) return resolve('');
pg.view.find(this, 'layout_xiaodi/btn_go').active = false;
pg.view.find(this, 'layout_xiaodi').active = true;
pg.view.find(this, 'layout_xiaodi').getComponent(dg_xiaodi).playEnter(this.data.npcAudio).then(() => {
resolve('');
})
});
}
endShowXiaodi() {
if (!this.data.npcAudio) return;
pg.view.find(this, 'layout_xiaodi').active = true;
pg.view.find(this, 'layout_xiaodi').getComponent(dg_xiaodi).playEnterEnd()
}
// update (dt) {}, // update (dt) {},
initView() { initView() {
let topTitle = cc.find("top/topTitle", this.node); let topTitle = cc.find("top/topTitle", this.node);
pg.view.touchOn(topTitle, this.playTopLaba, this); pg.view.touchOn(topTitle, this.playTopLaba, this);
this.showQuestion();
this.showGame();
} }
private touchOver() { private touchOver() {
this.playLocalAudio("finish"); this.playLocalAudio("finish");
...@@ -97,6 +118,37 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -97,6 +118,37 @@ export default class SceneComponent extends MyCocosSceneComponent {
console.log(data); console.log(data);
onHomeworkFinish(data); onHomeworkFinish(data);
} }
showXiaodi() {
if (!this.data.npcAudioEnd) return;
pg.view.find(this, 'layout_xiaodi/btn_go').active = false;
pg.view.touchOn(pg.view.find(this, 'layout_xiaodi/btn_go'), this.onTouchExit, this);
pg.view.setString(pg.view.find(this, 'layout_xiaodi/btn_go/txt'), this.data.npcAudioText)
if (!this.data.npcAudioText) {
pg.view.find(this, 'layout_xiaodi/btn_go').active = false
} else {
this.scheduleOnce(() => {
pg.view.find(this, 'layout_xiaodi/btn_go').active = true;
}, 0.5)
}
pg.view.find(this, 'layout_xiaodi').active = true;
pg.view.find(this, 'layout_xiaodi').getComponent(dg_xiaodi).playOver(this.data.npcAudioEnd)
}
hideXiaodi() {
if (!this.data.npcAudioEnd) return;
pg.view.find(this, 'layout_xiaodi').active = false;
pg.view.find(this, 'layout_xiaodi').getComponent(dg_xiaodi).playOverEnd()
}
onTouchExit() {
const middleLayer = cc.find('middleLayer')?.getComponent('middleLayer');
if (middleLayer) {
middleLayer.goNextPage(); // 跳转到下一页
// middleLayer.exitGame(null);
} else {
console.log("==触发返回事件==");
}
}
private gameOver() { private gameOver() {
this.scheduleOnce(() => { this.scheduleOnce(() => {
let btn_check = cc.find("btn_check", this.node); let btn_check = cc.find("btn_check", this.node);
...@@ -109,7 +161,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -109,7 +161,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}, 0.1) }, 0.1)
this.scheduleOnce(() => { this.scheduleOnce(() => {
// 展示小迪按钮 // 展示小迪按钮
this.showXiaodi();
}, 1.3) }, 1.3)
} }
private showGame() { private showGame() {
......
...@@ -22,34 +22,14 @@ export default class dg_xiaodi extends cc.Component { ...@@ -22,34 +22,14 @@ export default class dg_xiaodi extends cc.Component {
cc.tween(this.aniRole) cc.tween(this.aniRole)
.call(() => { .call(() => {
pg.view.playDBAnimation(this.aniRole, 'run'); pg.view.playDBAnimation(this.aniRole, 'run');
if (this.moveX < 0) {
this.aniRole.scaleX = -this.aniRole.scaleX;
}
}) })
.to(0.5, { x: 0 }) .to(0.5, { x: 510 })
.call(() => { .call(() => {
if (this.moveX < 0) {
this.aniRole.scaleX = -this.aniRole.scaleX;
}
pg.view.playDBAnimation(this.aniRole, 'talk'); pg.view.playDBAnimation(this.aniRole, 'talk');
pg.audio.playAudioByUrl(audioUrl, () => { pg.audio.playAudioByUrl(audioUrl, () => {
this.audioIdEnter = null; this.audioIdEnter = null;
cc.tween(this.aniRole)
.call(() => {
pg.view.playDBAnimation(this.aniRole, 'run');
if (this.moveX < 0) {
this.aniRole.scaleX = -this.aniRole.scaleX;
}
})
.to(0.5, { x: -1500 })
.call(() => {
this.scheduleOnce(() => {
resolve(''); resolve('');
}, 0.5)
})
.start();
}, audioId => { }, audioId => {
this.audioIdEnter = audioId; this.audioIdEnter = audioId;
}) })
...@@ -58,29 +38,24 @@ export default class dg_xiaodi extends cc.Component { ...@@ -58,29 +38,24 @@ export default class dg_xiaodi extends cc.Component {
}); });
} }
playEnterEnd() { playEnterEnd() {
this.node.active = false; pg.view.playDBAnimation(this.aniRole, 'normal');
if (this.audioIdEnter) { // this.node.active = false;
cc.audioEngine.stopEffect(this.audioIdEnter) // if (this.audioIdEnter) {
} // cc.audioEngine.stopEffect(this.audioIdEnter)
// }
} }
private audioIdOver: any; private audioIdOver: any;
playOver(audioUrl) { playOver(audioUrl) {
this.node.active = true; this.node.active = true;
let startX = this.defaultX + this.moveX; let startX = this.defaultX + this.moveX;
this.aniRole.x = startX; // this.aniRole.x = startX;
cc.tween(this.aniRole) // cc.tween(this.aniRole)
.call(() => { // .call(() => {
pg.view.playDBAnimation(this.aniRole, 'run'); // pg.view.playDBAnimation(this.aniRole, 'run');
if (this.moveX < 0) { // })
this.aniRole.scaleX = -this.aniRole.scaleX; // .to(0.3, { x: this.defaultX })
} // .call(() => {
})
.to(0.3, { x: this.defaultX })
.call(() => {
if (this.moveX < 0) {
this.aniRole.scaleX = -this.aniRole.scaleX;
}
pg.view.playDBAnimation(this.aniRole, 'talk'); pg.view.playDBAnimation(this.aniRole, 'talk');
pg.audio.playAudioByUrl(audioUrl, () => { pg.audio.playAudioByUrl(audioUrl, () => {
this.audioIdOver = null; this.audioIdOver = null;
...@@ -88,8 +63,8 @@ export default class dg_xiaodi extends cc.Component { ...@@ -88,8 +63,8 @@ export default class dg_xiaodi extends cc.Component {
}, audioId => { }, audioId => {
this.audioIdOver = audioId; this.audioIdOver = audioId;
}) })
}) // })
.start(); // .start();
} }
playOverEnd() { playOverEnd() {
this.node.active = false; this.node.active = false;
......
export const defaultData = { export const defaultData = {
"npcAudioText": "退出", "npcAudioText": "",
"npcAudio": "http://staging-teach.cdn.ireadabc.com/c14938125a52096dc0be9fbbf6638cb2_l.mp3", "npcAudio": "http://staging-teach.cdn.ireadabc.com/c14938125a52096dc0be9fbbf6638cb2_l.mp3",
"npcAudioName": "paomo_hy11_plp.mp3", "npcAudioName": "paomo_hy11_plp.mp3",
"npcAudioEnd": "http://staging-teach.cdn.ireadabc.com/c14938125a52096dc0be9fbbf6638cb2_l.mp3", "npcAudioEnd": "http://staging-teach.cdn.ireadabc.com/c14938125a52096dc0be9fbbf6638cb2_l.mp3",
......
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