Commit d744c78f authored by Tt's avatar Tt

敲碎

parent 35d3e306
......@@ -301,7 +301,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.layout.removeAllChildren();
const len = 5;
this.needScroll = true;
// this.needScroll = true;
const visibleData = pageData.slice(0, len);
this.pendingCandyData = pageData.slice(len);
visibleData.forEach((data, index) => {
......@@ -333,7 +333,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
* 移除了喷水动画相关代码
* @param e 事件对象或包含target属性的模拟事件对象
*/
private currentFireNode: CandyNode;
private currentTouchNode: CandyNode;
async onTouchItemNode(e) {
if (this.touching) return;
this.touching = true;
......@@ -341,7 +341,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 保存触摸数据
this.touchData = candyNode.data;
this.touchData.parent = candyNode;
this.currentFireNode = candyNode;
this.currentTouchNode = candyNode;
// 获取糖果节点的位置和背景节点
const bgFullNode = candyNode.getChildByName('bg_full');
......@@ -386,44 +386,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.showCard(true, 'init');
}
onFireSuccess() {
const fireNode = this.currentFireNode;
// 更新糖果背景状态:隐藏bg_full,显示bg_broken
const bgFullNode = fireNode.getChildByName('bg_full');
const bgBrokenNode = fireNode.getChildByName('bg_broken');
if (bgFullNode) {
bgFullNode.active = false;
}
if (bgBrokenNode) {
bgBrokenNode.active = true;
}
// 如果不需要滚动,则直接从活跃列表中移除并隐藏节点
if (!this.needScroll) {
// 从活跃火苗列表中移除当前火苗
const index = this.activeFireNodes.indexOf(fireNode);
if (index !== -1) {
this.activeFireNodes.splice(index, 1);
}
// 隐藏对应的fire节点
fireNode.active = false;
} else {
// 如果需要滚动,标记节点为已点击但保持显示状态
// 将节点设置为不可交互,防止重复点击
fireNode.off(cc.Node.EventType.TOUCH_END, this.onTouchItemNode, this);
}
// 移除了与页面a和页面b相关的逻辑
// 移除了与消防车冲水动画相关的代码
onRecordSuccess() {
const fireNode = this.currentTouchNode;
const index = this.activeFireNodes.indexOf(fireNode);
if (index !== -1) this.activeFireNodes.splice(index, 1);
fireNode.active = false;
this.touching = false;
// 重置无操作计时器
this.inactiveTimer = 0;
// 检查当前页面是否所有火苗都已处理完毕
if (this.activeFireNodes.length === 0) {
// 延迟一段时间后检查是否需要切换到下一页
......@@ -433,8 +403,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
}, 1.0); // 延迟1秒,给用户时间看到当前页面的完成状态
}
}
onFireFail() {
const fireNode = this.currentFireNode;
onRecordFail() {
const fireNode = this.currentTouchNode;
// 将火苗节点重新添加到活跃列表中,以便再次尝试
if (fireNode && !this.activeFireNodes.includes(fireNode)) {
......@@ -570,7 +540,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
showCard(show: boolean = true, recordState: string = 'init') {
if (show) {
// 显示卡片
const currentData = this.currentFireNode.data;
const currentData = this.currentTouchNode.data;
console.log('showCard', currentData)
this.layout_speak.active = true;
......@@ -672,7 +642,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
private renderProgressLabel(label_progress) {
// 获取当前正确答题的数量和总题目数量
// 使用player.right表示录音返回结果不是tryagain的答题数据数量
const correctAnswers = Game.getIns().player.right;
const correctAnswers = Game.getIns().player.voices.length;
const totalQuestions = Game.getIns().total;
// 设置进度文本 (正确答题数量)/(总数)
pg.view.setString(label_progress, `${correctAnswers + 1}/${totalQuestions}`);
......@@ -742,16 +712,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 获取最后一次录音数据
const lastVoice = Game.getIns().player.getLastVoice();
// 如果有录音数据,则使用其分数
if (lastVoice && lastVoice.result) {
if (lastVoice && lastVoice.result && lastVoice.questionId == this.touchData.id) {
const score = lastVoice.result.overall;
if (score >= 10) {
this.onFireSuccess();
this.onRecordSuccess();
} else {
this.onFireFail();
this.onRecordFail();
}
} else {
// 如果没有录音数据,默认失败
this.onFireFail();
this.onRecordFail();
}
}
......@@ -862,7 +832,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
"fluency": 84,
"integrity": 100,
"kernel_version": "3.7.1",
"overall": 8,
"overall": 68,
"pronunciation": 88,
"resource_version": "2.3.11",
"rhythm": 46,
......@@ -989,7 +959,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
// 增加正确计数
Game.getIns().player.addRight();
this.tryAgain = false;
// 如果有父节点(火苗节点),隐藏它
......@@ -1020,7 +989,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.showCard(false);
this.updateTips(null);
this.recordTouching = false;
this.onFireFail();
this.onRecordFail();
return;
}
} else {
......
......@@ -75,12 +75,6 @@ class Role {
addError(score: number = 1) {
this.error += score;
}
/**
* 增加正确次数
*/
addRight() {
this.right += 1;
}
/**
* 添加语音记录
* @param obj 语音对象
......
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