Commit f47733d4 authored by Tt's avatar Tt

成功流程完成

parent 42b79416
...@@ -6182,7 +6182,7 @@ ...@@ -6182,7 +6182,7 @@
"__id__": 119 "__id__": 119
}, },
"_children": [], "_children": [],
"_active": false, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 125 "__id__": 125
...@@ -6199,7 +6199,7 @@ ...@@ -6199,7 +6199,7 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 445, "width": 400,
"height": 508 "height": 508
}, },
"_anchorPoint": { "_anchorPoint": {
...@@ -6211,8 +6211,8 @@ ...@@ -6211,8 +6211,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
10.311, 0,
20.623, 0.332,
0, 0,
0, 0,
0, 0,
...@@ -6255,7 +6255,7 @@ ...@@ -6255,7 +6255,7 @@
"__uuid__": "f43e0539-0f77-4a83-82d2-2742f234e820" "__uuid__": "f43e0539-0f77-4a83-82d2-2742f234e820"
}, },
"_type": 0, "_type": 0,
"_sizeMode": 1, "_sizeMode": 0,
"_fillType": 0, "_fillType": 0,
"_fillCenter": { "_fillCenter": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
......
...@@ -498,33 +498,33 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -498,33 +498,33 @@ export default class SceneComponent extends MyCocosSceneComponent {
let btn_record_0 = pg.view.find(this.layout_speak, 'btn_record_0'); let btn_record_0 = pg.view.find(this.layout_speak, 'btn_record_0');
let btn_record_1 = pg.view.find(this.layout_speak, 'btn_record_1'); let btn_record_1 = pg.view.find(this.layout_speak, 'btn_record_1');
let btn_record_2 = pg.view.find(this.layout_speak, 'btn_record_2'); let btn_record_2 = pg.view.find(this.layout_speak, 'btn_record_2');
// 确保所有按钮都存在 // 确保所有按钮都存在
if (!btn_record_0 || !btn_record_1 || !btn_record_2) { if (!btn_record_0 || !btn_record_1 || !btn_record_2) {
return this.log('录音按钮节点不存在'); return this.log('录音按钮节点不存在');
} }
// 初始状态:显示第一个按钮,隐藏其他按钮 // 初始状态:显示第一个按钮,隐藏其他按钮
btn_record_0.active = true; btn_record_0.active = true;
btn_record_1.active = false; btn_record_1.active = false;
btn_record_2.active = false; btn_record_2.active = false;
// 清除可能存在的旧定时器 // 清除可能存在的旧定时器
if (this._voiceAniTimer) { if (this._voiceAniTimer) {
clearInterval(this._voiceAniTimer); clearInterval(this._voiceAniTimer);
this._voiceAniTimer = null; this._voiceAniTimer = null;
} }
// 当前显示的按钮索引 // 当前显示的按钮索引
let currentIndex = 0; let currentIndex = 0;
// 创建定时器,每隔200毫秒切换一次按钮显示 // 创建定时器,每隔200毫秒切换一次按钮显示
this._voiceAniTimer = setInterval(() => { this._voiceAniTimer = setInterval(() => {
// 隐藏所有按钮 // 隐藏所有按钮
btn_record_0.active = false; btn_record_0.active = false;
btn_record_1.active = false; btn_record_1.active = false;
btn_record_2.active = false; btn_record_2.active = false;
// 根据当前索引显示对应按钮 // 根据当前索引显示对应按钮
switch (currentIndex) { switch (currentIndex) {
case 0: case 0:
...@@ -537,12 +537,12 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -537,12 +537,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
btn_record_2.active = true; btn_record_2.active = true;
break; break;
} }
// 更新索引,循环显示三个按钮 // 更新索引,循环显示三个按钮
currentIndex = (currentIndex + 1) % 3; currentIndex = (currentIndex + 1) % 3;
}, 200); }, 200);
} }
/** /**
* 停止录音动画效果 * 停止录音动画效果
* 停止按钮切换,只显示btn_record_0 * 停止按钮切换,只显示btn_record_0
...@@ -553,26 +553,26 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -553,26 +553,26 @@ export default class SceneComponent extends MyCocosSceneComponent {
clearInterval(this._voiceAniTimer); clearInterval(this._voiceAniTimer);
this._voiceAniTimer = null; this._voiceAniTimer = null;
} }
// 获取录音按钮节点 // 获取录音按钮节点
let btn_record_0 = pg.view.find(this.layout_speak, 'btn_record_0'); let btn_record_0 = pg.view.find(this.layout_speak, 'btn_record_0');
let btn_record_1 = pg.view.find(this.layout_speak, 'btn_record_1'); let btn_record_1 = pg.view.find(this.layout_speak, 'btn_record_1');
let btn_record_2 = pg.view.find(this.layout_speak, 'btn_record_2'); let btn_record_2 = pg.view.find(this.layout_speak, 'btn_record_2');
// 确保所有按钮都存在 // 确保所有按钮都存在
if (!btn_record_0 || !btn_record_1 || !btn_record_2) { if (!btn_record_0 || !btn_record_1 || !btn_record_2) {
return this.log('录音按钮节点不存在'); return this.log('录音按钮节点不存在');
} }
// 只显示第一个按钮,隐藏其他按钮 // 只显示第一个按钮,隐藏其他按钮
btn_record_0.active = true; btn_record_0.active = true;
btn_record_1.active = false; btn_record_1.active = false;
btn_record_2.active = false; btn_record_2.active = false;
} }
// 录音动画定时器 // 录音动画定时器
private _voiceAniTimer: any = null; private _voiceAniTimer: any = null;
showCard(hide: boolean = false, recordState: string = 'init') { showCard(hide: boolean = false, recordState: string = 'init') {
if (!hide) { if (!hide) {
// 显示卡片 // 显示卡片
...@@ -588,6 +588,54 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -588,6 +588,54 @@ export default class SceneComponent extends MyCocosSceneComponent {
let btn_record_0 = pg.view.find(this.layout_speak, 'btn_record_0'); let btn_record_0 = pg.view.find(this.layout_speak, 'btn_record_0');
let btn_record_1 = pg.view.find(this.layout_speak, 'btn_record_1'); let btn_record_1 = pg.view.find(this.layout_speak, 'btn_record_1');
let btn_record_2 = pg.view.find(this.layout_speak, 'btn_record_2'); let btn_record_2 = pg.view.find(this.layout_speak, 'btn_record_2');
let bg_card = pg.view.find(this.layout_speak, 'bg_card');
let btn_voice = pg.view.find(bg_card, 'btn_voice');
let icon = pg.view.find(bg_card, 'icon');
let word = pg.view.find(bg_card, 'word');
let label_progress = pg.view.find(bg_card, 'label_progress');
// 任务1: 处理btn_voice按钮显示和音频播放
if (currentData.audioUrl) {
// 如果数据中有audio,显示语音按钮
pg.view.visible(btn_voice, true);
// 绑定点击事件播放音频
pg.view.touchOn(btn_voice, () => {
// 使用pg.ts的API播放音频
pg.audio.playAudioByUrl(currentData.audioUrl);
}, this);
} else {
// 没有音频则隐藏按钮
pg.view.visible(btn_voice, false);
}
// 任务2: 处理icon和word的显示逻辑
if (currentData.type === 'img') {
// 如果类型是img,显示图片,隐藏文字
pg.view.visible(icon, true);
pg.view.visible(word, false);
// 设置图片内容
if (currentData.picUrl) {
pg.view.setNetImg(icon, currentData.picUrl, { w: 945, h: 500 });
}
} else {
// 否则显示文字,隐藏图片
pg.view.visible(icon, false);
pg.view.visible(word, true);
// 设置文字内容
if (currentData.txt) {
pg.view.setString(word, currentData.txt);
}
}
// 任务3: 设置进度显示
// 获取当前正确答题的数量和总题目数量
// 使用player.right表示录音返回结果不是tryagain的答题数据数量
const correctAnswers = Game.getIns().player.right;
const totalQuestions = Game.getIns().total;
// 设置进度文本 (正确答题数量)/(总数)
pg.view.setString(label_progress, `${correctAnswers + 1}/${totalQuestions}`);
// 绑定按钮事件 // 绑定按钮事件
pg.view.touchOn(btn_start, this.onTouchRecord, this); pg.view.touchOn(btn_start, this.onTouchRecord, this);
......
...@@ -9,5 +9,30 @@ ...@@ -9,5 +9,30 @@
* @type {Object} * @type {Object}
*/ */
export const defaultData = { export const defaultData = {
"score": 0, "title": "", "questionText": "", "questionType": "read", "questionTextAudio": "", "bgAudio": "", "questions": [{ "type": "img", "audio": "http://staging-teach.cdn.ireadabc.com/ae2538a7ef5de1b4836a882d625271af_l.mp3", "text": "left", "image": "http://staging-teach.cdn.ireadabc.com/41b95f47d23e0712f825eec9e718caed.png", "time": null, "duration": 30, "audioName": "heal_money.mp3" }, { "type": "img", "audio": "http://staging-teach.cdn.ireadabc.com/4f3bb8f8fa048f40c1bb5d6d2f6d9a33_l.mp3", "text": "down", "image": "http://staging-teach.cdn.ireadabc.com/fbe3d792ce2a72310e5298e1d75d0d71.png", "time": null, "duration": 30, "audioName": "shoot.MP3" }, { "type": "img", "audio": "http://staging-teach.cdn.ireadabc.com/a6fb6452f0e383808cd056939ed81917_l.mp3", "text": "circle", "image": "http://staging-teach.cdn.ireadabc.com/d0652838333e892b5e495fbdd8746fa0.png", "time": null, "duration": 30, "audioName": "levelup.MP3" }, { "type": "txt", "audio": "http://staging-teach.cdn.ireadabc.com/e8d058205a1bc894c55a9dc46d60717f_l.mp3", "text": "shoot", "image": "", "time": null, "duration": 30, "audioName": "yasuo.mp3" }, { "type": "txt", "audio": "", "text": "apple", "image": "", "time": null, "duration": 30, "audioName": "" }, { "type": "txt", "audio": "", "text": "international", "image": "", "time": null, "duration": 30, "audioName": "" }, { "type": "txt", "audio": "", "text": "deep", "image": "", "time": null, "duration": 30, "audioName": "" }, { "type": "txt", "audio": "", "text": "fun", "image": "", "time": null, "duration": 10, "audioName": "" }] "score": 0, "title": "", "questionText": "", "questionType": "read",
"questionTextAudio": "", "bgAudio": "", "questions": [{
"type": "img",
"audio": "http://staging-teach.cdn.ireadabc.com/ae2538a7ef5de1b4836a882d625271af_l.mp3",
"text": "left",
"image": "http://staging-teach.cdn.ireadabc.com/41b95f47d23e0712f825eec9e718caed.png",
"time": null,
"duration": 30, "audioName": "heal_money.mp3"
}, {
"type": "img",
"audio": "http://staging-teach.cdn.ireadabc.com/4f3bb8f8fa048f40c1bb5d6d2f6d9a33_l.mp3",
"text": "down",
"image": "http://staging-teach.cdn.ireadabc.com/fbe3d792ce2a72310e5298e1d75d0d71.png", "time": null,
"duration": 30,
"audioName": "shoot.MP3"
}, {
"type": "img",
"audio": "http://staging-teach.cdn.ireadabc.com/a6fb6452f0e383808cd056939ed81917_l.mp3", "text": "circle", "image": "http://staging-teach.cdn.ireadabc.com/d0652838333e892b5e495fbdd8746fa0.png",
"time": null, "duration": 30,
"audioName": "levelup.MP3"
}, {
"type": "txt",
"audio": "http://staging-teach.cdn.ireadabc.com/e8d058205a1bc894c55a9dc46d60717f_l.mp3", "text": "shoot", "image": "",
"time": null, "duration": 30,
"audioName": "yasuo.mp3"
}, { "type": "txt", "audio": "", "text": "apple", "image": "", "time": null, "duration": 30, "audioName": "" }, { "type": "txt", "audio": "", "text": "international", "image": "", "time": null, "duration": 30, "audioName": "" }, { "type": "txt", "audio": "", "text": "deep", "image": "", "time": null, "duration": 30, "audioName": "" }, { "type": "txt", "audio": "", "text": "fun", "image": "", "time": null, "duration": 10, "audioName": "" }]
} }
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