Commit a64a96d6 authored by Tt's avatar Tt

修改完成

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