Commit 8b9dd890 authored by Tt's avatar Tt

逻辑处理

parent 541a830e
......@@ -87,22 +87,22 @@
"__id__": 91
},
{
"__id__": 124
"__id__": 125
},
{
"__id__": 137
"__id__": 139
}
],
"_active": true,
"_components": [
{
"__id__": 158
"__id__": 160
},
{
"__id__": 159
"__id__": 161
},
{
"__id__": 160
"__id__": 162
}
],
"_prefab": null,
......@@ -4548,37 +4548,37 @@
"__id__": 92
},
{
"__id__": 95
"__id__": 96
},
{
"__id__": 97
"__id__": 98
},
{
"__id__": 109
"__id__": 110
},
{
"__id__": 111
"__id__": 112
},
{
"__id__": 113
"__id__": 114
},
{
"__id__": 115
"__id__": 116
},
{
"__id__": 117
"__id__": 118
},
{
"__id__": 119
"__id__": 120
},
{
"__id__": 121
"__id__": 122
}
],
"_active": true,
"_components": [
{
"__id__": 123
"__id__": 124
}
],
"_prefab": null,
......@@ -4644,6 +4644,9 @@
},
{
"__id__": 94
},
{
"__id__": 95
}
],
"_prefab": null,
......@@ -4753,6 +4756,16 @@
"_originalHeight": 100,
"_id": "e4z3xJllFCB6KieFcf8UWG"
},
{
"__type__": "cc.BlockInputEvents",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 92
},
"_enabled": true,
"_id": "aaLLTNJ4JCrLs1MiLwHmnN"
},
{
"__type__": "cc.Node",
"_name": "btn_close",
......@@ -4764,7 +4777,7 @@
"_active": true,
"_components": [
{
"__id__": 96
"__id__": 97
}
],
"_prefab": null,
......@@ -4820,7 +4833,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 95
"__id__": 96
},
"_enabled": true,
"_materials": [
......@@ -4856,25 +4869,25 @@
},
"_children": [
{
"__id__": 98
"__id__": 99
},
{
"__id__": 100
"__id__": 101
},
{
"__id__": 102
"__id__": 103
},
{
"__id__": 104
"__id__": 105
},
{
"__id__": 106
"__id__": 107
}
],
"_active": true,
"_components": [
{
"__id__": 108
"__id__": 109
}
],
"_prefab": null,
......@@ -4930,13 +4943,13 @@
"_name": "bg_title",
"_objFlags": 0,
"_parent": {
"__id__": 97
"__id__": 98
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 99
"__id__": 100
}
],
"_prefab": null,
......@@ -4992,7 +5005,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 98
"__id__": 99
},
"_enabled": true,
"_materials": [
......@@ -5024,13 +5037,13 @@
"_name": "btn_voice",
"_objFlags": 0,
"_parent": {
"__id__": 97
"__id__": 98
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 101
"__id__": 102
}
],
"_prefab": null,
......@@ -5086,7 +5099,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 100
"__id__": 101
},
"_enabled": true,
"_materials": [
......@@ -5118,13 +5131,13 @@
"_name": "icon",
"_objFlags": 0,
"_parent": {
"__id__": 97
"__id__": 98
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 103
"__id__": 104
}
],
"_prefab": null,
......@@ -5180,7 +5193,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 102
"__id__": 103
},
"_enabled": true,
"_materials": [
......@@ -5212,13 +5225,13 @@
"_name": "word",
"_objFlags": 0,
"_parent": {
"__id__": 97
"__id__": 98
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 105
"__id__": 106
}
],
"_prefab": null,
......@@ -5274,7 +5287,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 104
"__id__": 105
},
"_enabled": true,
"_materials": [
......@@ -5307,13 +5320,13 @@
"_name": "label_progress",
"_objFlags": 0,
"_parent": {
"__id__": 97
"__id__": 98
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 107
"__id__": 108
}
],
"_prefab": null,
......@@ -5369,7 +5382,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 106
"__id__": 107
},
"_enabled": true,
"_materials": [
......@@ -5402,7 +5415,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 97
"__id__": 98
},
"_enabled": true,
"_materials": [
......@@ -5440,7 +5453,7 @@
"_active": true,
"_components": [
{
"__id__": 110
"__id__": 111
}
],
"_prefab": null,
......@@ -5496,7 +5509,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 109
"__id__": 110
},
"_enabled": true,
"_materials": [
......@@ -5534,7 +5547,7 @@
"_active": true,
"_components": [
{
"__id__": 112
"__id__": 113
}
],
"_prefab": null,
......@@ -5590,7 +5603,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 111
"__id__": 112
},
"_enabled": true,
"_materials": [
......@@ -5628,7 +5641,7 @@
"_active": true,
"_components": [
{
"__id__": 114
"__id__": 115
}
],
"_prefab": null,
......@@ -5684,7 +5697,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 113
"__id__": 114
},
"_enabled": true,
"_materials": [
......@@ -5722,7 +5735,7 @@
"_active": true,
"_components": [
{
"__id__": 116
"__id__": 117
}
],
"_prefab": null,
......@@ -5778,7 +5791,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 115
"__id__": 116
},
"_enabled": true,
"_materials": [
......@@ -5816,7 +5829,7 @@
"_active": true,
"_components": [
{
"__id__": 118
"__id__": 119
}
],
"_prefab": null,
......@@ -5872,7 +5885,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 117
"__id__": 118
},
"_enabled": true,
"_materials": [
......@@ -5910,7 +5923,7 @@
"_active": true,
"_components": [
{
"__id__": 120
"__id__": 121
}
],
"_prefab": null,
......@@ -5966,7 +5979,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 119
"__id__": 120
},
"_enabled": true,
"_materials": [
......@@ -6004,7 +6017,7 @@
"_active": true,
"_components": [
{
"__id__": 122
"__id__": 123
}
],
"_prefab": null,
......@@ -6060,7 +6073,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 121
"__id__": 122
},
"_enabled": true,
"_materials": [
......@@ -6123,10 +6136,7 @@
},
"_children": [
{
"__id__": 125
},
{
"__id__": 128
"__id__": 126
},
{
"__id__": 130
......@@ -6136,12 +6146,15 @@
},
{
"__id__": 134
},
{
"__id__": 136
}
],
"_active": false,
"_components": [
{
"__id__": 136
"__id__": 138
}
],
"_prefab": null,
......@@ -6197,16 +6210,19 @@
"_name": "gray",
"_objFlags": 0,
"_parent": {
"__id__": 124
"__id__": 125
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 126
"__id__": 127
},
{
"__id__": 127
"__id__": 128
},
{
"__id__": 129
}
],
"_prefab": null,
......@@ -6262,7 +6278,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 125
"__id__": 126
},
"_enabled": true,
"_materials": [
......@@ -6294,7 +6310,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 125
"__id__": 126
},
"_enabled": true,
"alignMode": 1,
......@@ -6316,18 +6332,28 @@
"_originalHeight": 100,
"_id": "41rT7ZWG1KjKrJ2VUG3N4b"
},
{
"__type__": "cc.BlockInputEvents",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 126
},
"_enabled": true,
"_id": "06Mffqf45GhK4NFe0w8hTw"
},
{
"__type__": "cc.Node",
"_name": "ani_comeon",
"_objFlags": 0,
"_parent": {
"__id__": 124
"__id__": 125
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 129
"__id__": 131
}
],
"_prefab": null,
......@@ -6383,7 +6409,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 128
"__id__": 130
},
"_enabled": true,
"_materials": [
......@@ -6423,13 +6449,13 @@
"_name": "ani_excellent",
"_objFlags": 0,
"_parent": {
"__id__": 124
"__id__": 125
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 131
"__id__": 133
}
],
"_prefab": null,
......@@ -6485,7 +6511,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 130
"__id__": 132
},
"_enabled": true,
"_materials": [
......@@ -6525,13 +6551,13 @@
"_name": "ani_nice",
"_objFlags": 0,
"_parent": {
"__id__": 124
"__id__": 125
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 133
"__id__": 135
}
],
"_prefab": null,
......@@ -6587,7 +6613,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 132
"__id__": 134
},
"_enabled": true,
"_materials": [
......@@ -6627,13 +6653,13 @@
"_name": "ani_tryagain",
"_objFlags": 0,
"_parent": {
"__id__": 124
"__id__": 125
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 135
"__id__": 137
}
],
"_prefab": null,
......@@ -6689,7 +6715,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 134
"__id__": 136
},
"_enabled": true,
"_materials": [
......@@ -6729,7 +6755,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 124
"__id__": 125
},
"_enabled": true,
"alignMode": 1,
......@@ -6760,19 +6786,19 @@
},
"_children": [
{
"__id__": 138
"__id__": 140
},
{
"__id__": 142
"__id__": 144
},
{
"__id__": 146
"__id__": 148
},
{
"__id__": 150
"__id__": 152
},
{
"__id__": 154
"__id__": 156
}
],
"_active": false,
......@@ -6830,11 +6856,11 @@
"_name": "quadBase",
"_objFlags": 0,
"_parent": {
"__id__": 137
"__id__": 139
},
"_children": [
{
"__id__": 139
"__id__": 141
}
],
"_active": true,
......@@ -6892,11 +6918,11 @@
"_name": "quad",
"_objFlags": 0,
"_parent": {
"__id__": 138
"__id__": 140
},
"_children": [
{
"__id__": 140
"__id__": 142
}
],
"_active": true,
......@@ -6954,13 +6980,13 @@
"_name": "paper",
"_objFlags": 0,
"_parent": {
"__id__": 139
"__id__": 141
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 141
"__id__": 143
}
],
"_prefab": null,
......@@ -7016,7 +7042,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 140
"__id__": 142
},
"_enabled": true,
"_materials": [
......@@ -7046,11 +7072,11 @@
"_name": "quadBase",
"_objFlags": 0,
"_parent": {
"__id__": 137
"__id__": 139
},
"_children": [
{
"__id__": 143
"__id__": 145
}
],
"_active": true,
......@@ -7108,11 +7134,11 @@
"_name": "quad",
"_objFlags": 0,
"_parent": {
"__id__": 142
"__id__": 144
},
"_children": [
{
"__id__": 144
"__id__": 146
}
],
"_active": true,
......@@ -7170,13 +7196,13 @@
"_name": "paper",
"_objFlags": 0,
"_parent": {
"__id__": 143
"__id__": 145
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 145
"__id__": 147
}
],
"_prefab": null,
......@@ -7232,7 +7258,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 144
"__id__": 146
},
"_enabled": true,
"_materials": [
......@@ -7262,11 +7288,11 @@
"_name": "quadBase",
"_objFlags": 0,
"_parent": {
"__id__": 137
"__id__": 139
},
"_children": [
{
"__id__": 147
"__id__": 149
}
],
"_active": true,
......@@ -7324,11 +7350,11 @@
"_name": "quad",
"_objFlags": 0,
"_parent": {
"__id__": 146
"__id__": 148
},
"_children": [
{
"__id__": 148
"__id__": 150
}
],
"_active": true,
......@@ -7386,13 +7412,13 @@
"_name": "paper",
"_objFlags": 0,
"_parent": {
"__id__": 147
"__id__": 149
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 149
"__id__": 151
}
],
"_prefab": null,
......@@ -7448,7 +7474,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 148
"__id__": 150
},
"_enabled": true,
"_materials": [
......@@ -7478,11 +7504,11 @@
"_name": "quadBase",
"_objFlags": 0,
"_parent": {
"__id__": 137
"__id__": 139
},
"_children": [
{
"__id__": 151
"__id__": 153
}
],
"_active": true,
......@@ -7540,11 +7566,11 @@
"_name": "quad",
"_objFlags": 0,
"_parent": {
"__id__": 150
"__id__": 152
},
"_children": [
{
"__id__": 152
"__id__": 154
}
],
"_active": true,
......@@ -7602,13 +7628,13 @@
"_name": "paper",
"_objFlags": 0,
"_parent": {
"__id__": 151
"__id__": 153
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 153
"__id__": 155
}
],
"_prefab": null,
......@@ -7664,7 +7690,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 152
"__id__": 154
},
"_enabled": true,
"_materials": [
......@@ -7694,11 +7720,11 @@
"_name": "quadBase",
"_objFlags": 0,
"_parent": {
"__id__": 137
"__id__": 139
},
"_children": [
{
"__id__": 155
"__id__": 157
}
],
"_active": true,
......@@ -7756,11 +7782,11 @@
"_name": "quad",
"_objFlags": 0,
"_parent": {
"__id__": 154
"__id__": 156
},
"_children": [
{
"__id__": 156
"__id__": 158
}
],
"_active": true,
......@@ -7818,13 +7844,13 @@
"_name": "paper",
"_objFlags": 0,
"_parent": {
"__id__": 155
"__id__": 157
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 157
"__id__": 159
}
],
"_prefab": null,
......@@ -7880,7 +7906,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 156
"__id__": 158
},
"_enabled": true,
"_materials": [
......@@ -7961,7 +7987,7 @@
"__id__": 34
},
"layout_tip": {
"__id__": 124
"__id__": 125
},
"layout_speak": {
"__id__": 91
......@@ -7985,7 +8011,7 @@
"__id__": 65
},
"btn_close": {
"__id__": 95
"__id__": 96
},
"_id": "db3L+4L+FH/5MIRcKcfiq+"
}
......
......@@ -361,7 +361,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 根据火苗编号调整消防车位置
// fire_0~fire_2 消防车位置 x=-400,fire_3~fire_5 消防车位置 x=-185
// 并根据当前页码进行偏移
const baseXList = [-400, -420, -400, -175, -215, -175]
const baseXList = [-420, -430, -400, -195, -225, -175]
const baseX = baseXList[fireIndex];
const targetX = baseX + 1920 * currentPage;
......@@ -414,7 +414,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
onFireSuccess() {
pg.hw.playLocalAudio('score_success');
const fireNode = this.currentFireNode;
// 从活跃火苗列表中移除当前火苗 --- 答题后操作
const index = this.activeFireNodes.indexOf(fireNode);
......@@ -442,10 +441,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
pg.view.playDBAnimation(this.node_firetruck_flush, '收水', 1);
setTimeout(() => {
this.scheduleOnce(() => {
this.node_firetruck_flush.active = false;
}, 2000);
this.touching = false;
this.touching = false;
}, 1);
// 检查当前页面是否所有火苗都已处理完毕
if (this.activeFireNodes.length === 0) {
......@@ -457,7 +456,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
onFireFail() {
pg.hw.playLocalAudio('score_fail');
const fireNode = this.currentFireNode;
// 将火苗节点重新添加到活跃列表中,以便再次尝试
......@@ -469,6 +467,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
if (fireNode) {
fireNode.active = true;
}
pg.view.playDBAnimation(this.node_firetruck_flush, '收水', 1);
this.scheduleOnce(() => {
this.node_firetruck_flush.active = false;
this.touching = false;
}, 1);
}
nextPage() {
// 切换到下一页
......@@ -569,6 +572,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 录音动画定时器
private _voiceAniTimer: any = null;
/**
* 显示或隐藏卡片
* @param show 是否显示卡片,默认为true
* @param recordState 录音状态,默认为'init'
*/
showCard(show: boolean = true, recordState: string = 'init') {
if (show) {
// 显示卡片
......@@ -582,95 +590,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
let btn_stop = pg.view.find(this.layout_speak, 'btn_stop');
let btn_record_replay = pg.view.find(this.layout_speak, 'btn_record_replay');
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);
}
// 渲染卡片内容(语音按钮、图标、文字、进度)
if (recordState == 'init') {
this.renderCardContent(bg_card, currentData);
// 绑定按钮事件
this.bindCardButtonEvents(btn_start, btn_start_reset, btn_stop, btn_record_replay);
}
// 任务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_reset, this.onTouchRecord, this);
pg.view.touchOn(btn_stop, this.onTouchRecordEnd, this);
pg.view.touchOn(btn_record_replay, this.onTouchPlayRecord, this);
// 根据录音状态显示不同的按钮
switch (recordState) {
case 'init': // 初始状态,未录制
pg.hw.playLocalAudio('pop_card');
btn_start.active = true;
btn_stop.active = false;
btn_start_reset.active = false;
btn_record_replay.active = false;
// 停止录音动画,显示初始状态
this.stopVoiceAni();
break;
case 'recording': // 录制中
btn_start.active = false;
btn_stop.active = true;
btn_start_reset.active = false;
btn_record_replay.active = false;
// 开始播放录音动画
this.playVoiceAni();
break;
case 'recorded': // 录制完成
btn_start.active = false;
btn_stop.active = false;
btn_start_reset.active = true;
btn_record_replay.active = true;
// 停止录音动画,显示初始状态
this.stopVoiceAni();
break;
default: // 默认显示初始状态
btn_start.active = true;
btn_stop.active = false;
btn_start_reset.active = false;
btn_record_replay.active = false;
// 停止录音动画,显示初始状态
this.stopVoiceAni();
}
// 根据录音状态设置按钮显示
this.updateButtonsByRecordState(recordState, btn_start, btn_stop, btn_start_reset, btn_record_replay);
} else {
// 隐藏录音界面
this.layout_speak.active = false;
......@@ -678,6 +607,145 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.stopVoiceAni();
}
}
/**
* 渲染卡片内容(语音按钮、图标、文字、进度)
* @param bg_card 卡片背景节点
* @param currentData 当前题目数据
*/
private renderCardContent(bg_card, currentData) {
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');
// 处理btn_voice按钮显示和音频播放
this.renderVoiceButton(btn_voice, currentData);
// 处理icon和word的显示逻辑
this.renderIconAndWord(icon, word, currentData);
// 设置进度显示
this.renderProgressLabel(label_progress);
}
/**
* 处理语音按钮的显示和事件绑定
* @param btn_voice 语音按钮节点
* @param currentData 当前题目数据
*/
private renderVoiceButton(btn_voice, currentData) {
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);
}
}
/**
* 处理图标和文字的显示逻辑
* @param icon 图标节点
* @param word 文字节点
* @param currentData 当前题目数据
*/
private renderIconAndWord(icon, word, currentData) {
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);
}
}
}
/**
* 设置进度标签显示
* @param label_progress 进度标签节点
*/
private renderProgressLabel(label_progress) {
// 获取当前正确答题的数量和总题目数量
// 使用player.right表示录音返回结果不是tryagain的答题数据数量
const correctAnswers = Game.getIns().player.right;
const totalQuestions = Game.getIns().total;
// 设置进度文本 (正确答题数量)/(总数)
pg.view.setString(label_progress, `${correctAnswers + 1}/${totalQuestions}`);
}
/**
* 绑定卡片按钮事件
* @param btn_start 开始按钮节点
* @param btn_start_reset 重新开始按钮节点
* @param btn_stop 停止按钮节点
* @param btn_record_replay 回放按钮节点
*/
private bindCardButtonEvents(btn_start, btn_start_reset, btn_stop, btn_record_replay) {
pg.view.touchOn(btn_start, this.onTouchRecord, this);
pg.view.touchOn(btn_start_reset, this.onTouchRecord, this);
pg.view.touchOn(btn_stop, this.onTouchRecordEnd, this);
pg.view.touchOn(btn_record_replay, this.onTouchPlayRecord, this);
}
/**
* 根据录音状态更新按钮显示
* @param recordState 录音状态
* @param btn_start 开始按钮节点
* @param btn_stop 停止按钮节点
* @param btn_start_reset 重新开始按钮节点
* @param btn_record_replay 回放按钮节点
*/
private updateButtonsByRecordState(recordState, btn_start, btn_stop, btn_start_reset, btn_record_replay) {
switch (recordState) {
case 'init': // 初始状态,未录制
pg.hw.playLocalAudio('pop_card');
btn_start.active = true;
btn_stop.active = false;
btn_start_reset.active = false;
btn_record_replay.active = false;
// 停止录音动画,显示初始状态
this.stopVoiceAni();
break;
case 'recording': // 录制中
btn_start.active = false;
btn_stop.active = true;
btn_start_reset.active = false;
btn_record_replay.active = false;
// 开始播放录音动画
this.playVoiceAni();
break;
case 'recorded': // 录制完成
btn_start.active = false;
btn_stop.active = false;
btn_start_reset.active = true;
btn_record_replay.active = true;
// 停止录音动画,显示初始状态
this.stopVoiceAni();
break;
default: // 默认显示初始状态
btn_start.active = true;
btn_stop.active = false;
btn_start_reset.active = false;
btn_record_replay.active = false;
// 停止录音动画,显示初始状态
this.stopVoiceAni();
}
}
onTouchSpeakClose() {
this.showCard(false);
......@@ -746,7 +814,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
"fluency": 84,
"integrity": 100,
"kernel_version": "3.7.1",
"overall": 83,
"overall": 8,
"pronunciation": 88,
"resource_version": "2.3.11",
"rhythm": 46,
......@@ -836,8 +904,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.log("recrodEnd!!!!!")
// 将当前题目ID添加到录音数据中
data.questionId = this.touchData.id;
// 保存录音数据
Game.getIns().player.addVoice(data);
// 获取评分和检查单词正确性
let score = data.result.overall;
......@@ -853,15 +919,25 @@ export default class SceneComponent extends MyCocosSceneComponent {
if (score >= 80) {
// 80分及以上,显示优秀提示(3星)
this.updateTips(TIPS_STATE.EXCELLENT);
pg.hw.playLocalAudio('score_success');
// 保存录音数据
Game.getIns().player.addVoice(data);
} else if (score >= 60) {
// 60-80分,显示不错提示(2星)
this.updateTips(TIPS_STATE.NICE);
pg.hw.playLocalAudio('score_success');
// 保存录音数据
Game.getIns().player.addVoice(data);
} else if (score >= 10) {
// 10-60分,显示加油提示(1星)
this.updateTips(TIPS_STATE.COMEON);
pg.hw.playLocalAudio('score_success');
// 保存录音数据
Game.getIns().player.addVoice(data);
} else {
// 10分以下,显示再试一次提示(0星)
this.updateTips(TIPS_STATE.TRYAGAIN);
pg.hw.playLocalAudio('score_fail');
}
// 增加正确计数
......
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