Commit 5c29605e authored by liujiangnan's avatar liujiangnan

feat: 自动录音

parent fda22160
......@@ -1983,7 +1983,7 @@
"__id__": 40
},
"_children": [],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 47
......
......@@ -29,7 +29,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
_status = {
currentTipAudioId: null,
canClick: true,
currentSelectedCard: null,
tryAgainFlg: false,
......@@ -177,9 +176,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
if (cc.find('Canvas/mask').active) {
return;
}
this.playLocalAudio('tips', (id) => {
this._status.currentTipAudioId = id;
});
await this.userSpeak();
await this.hideCards(card, this._status.currentSelectedCard);
this.checkQuestionOver();
......@@ -326,7 +322,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
mask.active = false;
this._status = {
canClick: true,
currentTipAudioId: null,
currentSelectedCard: null,
tryAgainFlg: false,
starLength: 0,
......@@ -370,10 +365,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
});
}
userSpeak() {
async userSpeak() {
const word = this._status.currentSelectedCard['word'];
return new Promise((resolve, reject) => {
console.log('userSpeak: ' + word);
const baseSpeaker = cc.find('Canvas/bg/speaker');
baseSpeaker.active = true;
const bg = baseSpeaker.getChildByName('bg');
......@@ -381,60 +374,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
.set({ opacity: 0 })
.to(0.5, { opacity: 100 })
.start();
const speaker = baseSpeaker.getChildByName('speaker');
const btnStart = baseSpeaker.getChildByName('btnStart');
const btnStop = baseSpeaker.getChildByName('btnStop');
btnStart.active = true;
btnStart['canClick'] = true;
btnStart.off('click');
btnStart.on('click', () => {
if (typeof (this._status.currentTipAudioId) == 'number') {
cc.audioEngine.stop(this._status.currentTipAudioId);
}
const word = this._status.currentSelectedCard['word'];
if (!btnStart['canClick']) {
return;
}
this.playLocalAudio('btn');
btnStart['canClick'] = false;
asyncPlayDragonBoneAnimation(speaker, 'newAnimation', -1);
cc.tween(btnStart)
.to(0.1, { scale: 1.1 })
.to(0.1, { scale: 1.0 })
.call(() => {
btnStart.active = false;
btnStop.active = true;
btnStart['canClick'] = true;
})
.start();
if (window['courseware']) {
window['courseware'].startTest(word);
this._status.isRecording = true;
} else {
console.log('word = ' + word);
}
});
btnStop['canClick'] = true;
btnStop.off('click');
btnStop.on('click', () => {
if (!btnStop['canClick']) {
return;
}
this.playLocalAudio('btn');
btnStop['canClick'] = false;
cc.tween(btnStop)
.to(0.1, { scale: 1.1 })
.to(0.1, { scale: 1.0 })
.call(async () => {
btnStop['canClick'] = true;
btnStop.active = false;
await asyncDelay(5);
const dragonDisplay = speaker.getComponent(dragonBones.ArmatureDisplay);
dragonDisplay.playAnimation('newAnimation', -1);
dragonDisplay.timeScale = 0.00000001;
......@@ -445,45 +393,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
await this.showGoodjob();
baseSpeaker.active = false;
this._status.tryAgainFlg = false;
resolve(null);
} else {
this.playLocalAudio('try_again');
const tryAgain = cc.find('Canvas/bg/speaker/tryAgain');
await this.showTryAgain();
if (!this._status.tryAgainFlg) {
this._status.tryAgainFlg = true;
tryAgain.active = false;
btnStart.active = true;
} else {
const skip = baseSpeaker.getChildByName('skip');
const doItAgain = baseSpeaker.getChildByName('doItAgain');
skip.active = true;
doItAgain.active = true;
skip.once('click', () => {
this.playLocalAudio('btn');
baseSpeaker.active = false;
tryAgain.active = false;
skip.active = false;
doItAgain.active = false;
this._status.tryAgainFlg = false;
console.log('喵喵喵');
resolve(null);
});
doItAgain.once('click', () => {
this.playLocalAudio('btn');
tryAgain.active = false;
btnStart.active = true;
skip.active = false;
doItAgain.active = false;
});
}
btnStop.active = false;
}
})
.start();
});
});
}
stopTest() {
......@@ -561,7 +475,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
this._status = {
canClick: true,
currentSelectedCard: null,
currentTipAudioId: null,
tryAgainFlg: false,
starLength: 0,
getStarNumber: 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