Commit 776060bf authored by Tt's avatar Tt

hy01修改

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