Commit ddede972 authored by Tt's avatar Tt

待提供无黑边图片

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