Commit 776060bf authored by Tt's avatar Tt

hy01修改

parent 83c91eb1
......@@ -2,6 +2,7 @@
// letter: 'test',
// targetTime: 10
// })
// pg.event.emit('layer_record_close')
//pg.event.on('layer_record_start_record',()=>{});
//pg.event.on('layer_record_end_record',()=>{});
......@@ -33,6 +34,13 @@ export default class LayerRecord extends cc.Component {
this.letter = data.letter
this.targetTime = data.targetTime
})
pg.event.on('layer_record_close', (data) => {
this.layout_record.active = false;
if (this.recordAudioId) {
cc.audioEngine.stopEffect(this.recordAudioId)
}
this.playVoiceEnd();
})
let btn_record = pg.view.find(this.layout_record, 'btn_record');
let btn_play = pg.view.find(this.layout_record, 'btn_play');
btn_record.on(cc.Node.EventType.TOUCH_START, this.onTouchRecord, this);
......@@ -143,6 +151,7 @@ export default class LayerRecord extends cc.Component {
this.showTimeStart();
cc.audioEngine.stopAllEffects();
pg.event.emit('layer_record_start_record');
courseware && courseware.startTest(this.letter); //开始录音
}
async onTouchRecordEnd() {
......@@ -170,6 +179,7 @@ export default class LayerRecord extends cc.Component {
"tokenId": "6144295408558b08dd000001",
"applicationId": "154838659000009e"
}
pg.event.emit('layer_record_end_record');
if (!courseware) {
return this.recrodEnd(testData)
}
......
......@@ -45,13 +45,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
private recordFlag: boolean;//录音模式
private score: number;
private scoreList: Array<number>;
private tempScore: number;
private tempCount: number;
initData() {
// 所有全局变量 默认都是null
this._cantouch = true;
let data = this.data;
this.score = 0;
this.tempScore = 0;
this.tempCount = 0;
this.recordFlag = data.recordFlag;
this.list = data.questions[0].options;
this.scoreList = this.list.map(() => 3);
......@@ -92,7 +92,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
lastPage() {
this.lastLayer();
// 停止当前所有动作
this.preLayer();
}
nextPage() {
this.nextLayer();
......@@ -136,10 +137,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
private get OutLayer() {
return this.layers[this.count + 2]
}
private voiceTouchForbid: boolean;
private count: number;
initGame() {
this.count = 0;
this.touchForbid = true;
this.voiceTouchForbid = true;
let currentLayer = this.createLayer();
this.updateLayer(currentLayer, this.CurrentData)
this.layers.push(currentLayer)
......@@ -149,11 +152,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
startGame() {
this.touchForbid = false;
this.voiceTouchForbid = false;
this.startPlay();
}
private currentAudioId: any;
startPlay() {
this.touchForbid = false;
if (this.recordFlag) {
this.touchForbid = false;
pg.event.emit('layer_record_open', {
letter: this.CurrentData.content,
targetTime: this.CurrentData.duration
......@@ -164,12 +169,17 @@ export default class SceneComponent extends MyCocosSceneComponent {
let com = img_voice.getComponent(ImgVoice);
com.playVoiceStart();
pg.audio.playAudioByUrl(this.CurrentData.audio, () => {
this.currentAudioId = null;
com.playVoiceEnd();
this.touchForbid = true;
pg.event.once('layer_coin_show_coin_end', () => {
this.touchForbid = false;
this.nextLayer();
}) // 动画回调\
this.score += 3;
pg.event.emit('layer_coin_show_coin', 3) //1 2 3硬币数量
}, (audioId) => {
this.currentAudioId = audioId;
})
}
}
......@@ -185,13 +195,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.score += 1;
this.scoreList[this.count] -= 1;
}
this.tempScore = 0;
}
onRecorScore(score) {
if (score < 10) {
pg.event.once('layer_right_show_tryagain_end', () => {
this.tempScore += 1;
if (this.tempScore == 2) {
this.tempCount += 1;
if (this.tempCount == 2) {
this.addScore(1);
pg.event.once('layer_coin_show_coin_end', () => {
this.nextLayer();
......@@ -227,16 +236,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg.event.emit('layer_right_show_excellent')
}
}
lastLayer() {
alert("上一题")
preLayer() {
// 积分需要计算,未获取的内容
if (!this.LastData) return;
this.tempCount = 0;
cc.audioEngine.stopEffect(this.currentAudioId);
pg.event.emit('img_voice_play_voice_end');
pg.event.emit('layer_record_close');
cc.tween(this.lastLayer).to(3, { x: 0, y: 0, scale: 1 }).start();
cc.tween(this.LastLayer).to(3, { x: 0, y: 0, scale: 1 }).start();
cc.tween(this.CurrentLayer).to(3, { x: this.layer_word_little.x, y: this.layer_word_little.y, scale: this.layer_word_little.scale }).start();
if (this.nextLayer) {
cc.tween(this.nextLayer).to(3, { x: -1500 }).start();
if (this.LittleLayer) {
cc.tween(this.LittleLayer).to(3, { x: -1500 }).start();
}
this.scheduleOnce(() => {
this.count--;
......@@ -249,6 +260,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.gameOver();
return;
}
this.tempCount = 0;
pg.event.emit('layer_record_close');
this.currentAudioId && cc.audioEngine.stopEffect(this.currentAudioId);
pg.event.emit('img_voice_play_voice_end');
// 停止当前所有动作
if (this.OutData && !this.OutLayer) {
let outLayer = this.createLittleLayer();
this.updateLayer(outLayer, this.OutData)
......@@ -264,6 +280,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
cc.tween(this.OutLayer).to(3, { x: this.layer_word_little.x, y: this.layer_word_little.y }).start();
}
this.scheduleOnce(() => {
this.touchForbid = false;
this.count++;
this.startPlay();
}, 3)
......@@ -275,7 +292,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.startGame();
}
gameOver() {
pg.event.on('layer_ending_touch_replay', () => {
pg.event.once('layer_ending_touch_replay', () => {
this.replay();
})
pg.event.emit('layer_ending_show', { coin: this.score })
......@@ -321,6 +338,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
onTouchVoice(e) {
if (this.voiceTouchForbid) return;
let layer = e.target.parent;
if (layer === this.CurrentLayer) {
let img_voice = pg.view.find(this.CurrentLayer, 'voice/img_voice');
......
......@@ -15,7 +15,7 @@ export const defaultData =
// }], "bgAudio": "", "bgAudioName": "", "audioName": "", "npcTitle": "123", "npcAudio": "http://staging-teach.cdn.ireadabc.com/f96fcb73dc6b3dcf2ce71fe2ba76e4c3_l.mp3", "npcAudioName": "选项正确.mp3"
// }
{
"recordFlag": false,
"recordFlag": true,
"title": "test",
"audio_url": '',
npcTitle: "I show info",
......
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