Commit ddede972 authored by Tt's avatar Tt

待提供无黑边图片

parent eb692f80
This diff is collapsed.
......@@ -76,6 +76,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.scoreList = this.list.map(() => 3);
this.maxCurrent = 0;
this.layers = [];
this.readyNext = false;
this.readyTime = 99999;
}
private layers: Array<cc.Node>;
......@@ -91,6 +93,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg.view.touchOn(this.btn_last, this.preLayer, this);
pg.view.touchOn(this.btn_next, this.nextLayer, this);
pg.view.touchOn(this.btn_record, this.onTouchRecord, this);
pg.view.touchOn(this.img_npc, this.onPlayNpc, this);
pg.view.touchOn(this.ani_npc, this.onPlayNpc, this);
let layout_btns = pg.view.find(this.btn_record, "mask/layout_btns");
......@@ -171,9 +174,17 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.btn_last.active = this.showLastNext > 0 && !!this.LastData;
this.btn_next.active = this.showLastNext > 0 && !!this.NextData;
}
private readyNext: boolean;
private readyTime: number;
update(dt) {
if (!this.list) return;
this.updateBtns(dt);
this.readyTime -= dt;
if (this.readyNext && this.readyTime <= 0) {
this.readyNext = false;
this.readyTime = 999999;
this.nextLayer();
}
}
//--------------------------------Record-----------------------------
private recordAudio: string;
......@@ -205,6 +216,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
showRecordHide() {
this.showRecordWaitEnd();
this.img_npc.active = false;
this.showLastNext = 3;// 3秒显示时间
let img_voice = pg.view.find(this.btn_record, "img_voice");
img_voice.active = false;
......@@ -252,6 +264,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
private recordAudioId: any;
async showRecorAudioPlay() {
if (!this.recordAudio) return;
this.readyNext = false;
this.readyTime = 999999;
let layout_btns = pg.view.find(this.btn_record, "mask/layout_btns");
let btn_right = pg.view.find(layout_btns, 'btn_right')
......@@ -266,7 +280,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.showRecorAudioPlayEnd().then(() => {
this.showNpcAudioPlay().then(() => {
this.showNpcAudioPlayEnd();
this.nextLayer();
this.readyNext = true;
this.readyTime = 3;
})
})
}, audioId => {
......@@ -311,13 +326,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
ani_good: cc.Node = null;
@property(cc.Node)
ani_npc: cc.Node = null;
@property(cc.Node)
img_npc: cc.Node = null;
private npcAudioId: any;
showNpcAudioPlay() {
return new Promise((resolve, reject) => {
this.ani_npc.active = true;
this.img_npc.active = false;
pg.view.playDBAnimation(this.ani_npc, 'newAnimation', 0);
pg.audio.playAudioByUrl(this.CurrentData.npcAudio, () => {
pg.view.playDBAnimation(this.ani_npc, 'newAnimation', 1);
this.ani_npc.active = false;
this.img_npc.active = true;
this.npcAudioId = null;
resolve('');
}, audioId => {
......@@ -339,10 +359,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
// 停止播放录音
onTouchRecordStop() {
this.readyNext = false;
this.readyTime = 999999;
this.showRecorAudioPlayEnd().then(() => {
this.showNpcAudioPlay().then(() => {
this.showNpcAudioPlayEnd();
this.nextLayer();
this.readyNext = true;
this.readyTime = 3;
})
})
}
......@@ -352,10 +375,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.showRecorAudioPlay();
}
onPlayNpc() {
this.readyNext = false;
this.readyTime = 999999;
this.showNpcAudioPlayEnd();
this.showNpcAudioPlay().then(() => {
this.showNpcAudioPlayEnd();
this.nextLayer();
this.readyNext = true;
this.readyTime = 3;
})
}
//按钮触发,使用的方法
......@@ -378,7 +404,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.showRecordEnd();
let testData = {
"text": "Yes, there is.Yes, there is.Yes, there is.Yes, there is.Yes, there is.Yes, there is.Yes, there is.",
"audio": "https://staging-teach.cdn.ireadabc.com/6ee3ccaa831a884f02c6a75c6f647cb5.wav"
"audioUrl": "https://staging-teach.cdn.ireadabc.com/6ee3ccaa831a884f02c6a75c6f647cb5.wav"
}
if (!courseware) return this.recrodEnd(testData)
courseware && courseware.stopRecord(0, (data) => {
......@@ -389,7 +415,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
async recrodEnd(data) {
this.voiceTouchForbid = false;
this.recordAudio = data.audio;
this.recordAudio = data.audioUrl;
this.recordAudioWord = data.text;
this.recording = false;
this.showRecorAudioPlay();
......
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