Commit a09c7206 authored by 李维's avatar 李维

修复问题

1. 修复音频可以叠加播放的问题
2. 分数部分可以配置不显示
parent ba9261eb
...@@ -209,50 +209,58 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -209,50 +209,58 @@ export default class SceneComponent extends MyCocosSceneComponent {
subScorePanels = []; subScorePanels = [];
totalScorePanel = null; totalScorePanel = null;
initScorePanel() { initScorePanel() {
// 总分节点 // 设置总分节点
// this.totalScorePanel = let totalScore = 0;
if(!isNaN(this.data.totalScoreHotZoneIndex)) { // 若果索引不是数字 或者 索引小于0 则认为是没有配置索引
const totalNode = this.setScorePanel(this.data.hotZoneItemArr[this.data.totalScoreHotZoneIndex], 15); if(isNaN(Number(this.data.totalScoreHotZoneIndex)) || Number(this.data.totalScoreHotZoneIndex) < 0) {
totalNode.score = 0;
totalNode.totalScore = 0;
this.totalScorePanel = totalNode;
} else {
this.totalScorePanel = { this.totalScorePanel = {
node: null, node: null,
setScore: ()=>{0}, setScore: (score)=>{},
score: 0, initTotalScore: (score)=>{}
totalScore: 0,
} }
} else {
this.totalScorePanel = this.setScorePanel(this.data.hotZoneItemArr[this.data.totalScoreHotZoneIndex]);
} }
// 计算每个分数显示区的数据 // 计算每个分数显示区的数据
this.subScorePanels = []; this.subScorePanels = [];
this.data.scoreConfigArr.forEach(scoreConfig => { this.data.scoreConfigArr.forEach(scoreConfig => {
if(isNaN(Number(scoreConfig.linkHotZoneIndex))) { // 若果索引不是数字 或者 索引小于0 则认为是没有配置索引
if(isNaN(Number(scoreConfig.linkHotZoneIndex)) || Number(scoreConfig.linkHotZoneIndex) < 0) {
this.subScorePanels.push({
node: null,
setScore: (score)=>{},
initTotalScore: (score)=>{}
});
return return
} }
const config = this.setScorePanel(this.data.hotZoneItemArr[scoreConfig.linkHotZoneIndex], 15); const config = this.setScorePanel(this.data.hotZoneItemArr[Number(scoreConfig.linkHotZoneIndex)]);
config.score = 0; let subTotalScore = 0;
config.totalScore = 0;
scoreConfig.linkHotZoneIndexArr.forEach(scoreItemIndex => { scoreConfig.linkHotZoneIndexArr.forEach(scoreItemIndex => {
const contentItem = this.data.hotZoneConfigArr[scoreItemIndex]; const contentItem = this.data.hotZoneConfigArr[scoreItemIndex];
// 类型4 热区多选组 分数存储在选项中 -- 其他类型存储在contentItem中 // 类型4 热区多选组 分数存储在选项中 -- 其他类型存储在contentItem中
if(contentItem.hotZoneType == "4") { if(contentItem.hotZoneType == "4") {
contentItem.contentList.forEach(item => { contentItem.contentList.forEach(item => {
if(item.score && !isNaN(Number(item.score))) { if(item.score && !isNaN(Number(item.score))) {
config.totalScore += Number(item.score); subTotalScore += Number(item.score);
} }
}); });
} else { } else {
if(contentItem.score && !isNaN(Number(contentItem.score))) { if(contentItem.score && !isNaN(Number(contentItem.score))) {
config.totalScore += Number(contentItem.score); subTotalScore += Number(contentItem.score);
} }
} }
}); });
// 设置分数区域总分 - 显示
config.initTotalScore(subTotalScore);
// 统计全部总分 // 统计全部总分
this.totalScorePanel.totalScore += config.totalScore; totalScore += subTotalScore;
// 存全局数组 在提交时设置分时 // 存全局数组 在提交时设置分时
this.subScorePanels.push(config); this.subScorePanels.push(config);
}); });
// 设置总分 - 显示
this.totalScorePanel.initTotalScore(totalScore);
} }
// 检查是否可以提交 - 完成全部配置的问题 // 检查是否可以提交 - 完成全部配置的问题
...@@ -564,15 +572,20 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -564,15 +572,20 @@ export default class SceneComponent extends MyCocosSceneComponent {
currentAudioPlay = null; currentAudioPlay = null;
setOneAudioBtn(contentData, hotZoneItemData) { setOneAudioBtn(contentData, hotZoneItemData) {
const {sprNode} = this.newSprNodeByResName(hotZoneItemData, "icon_play_audio"); const {sprNode} = this.newSprNodeByResName(hotZoneItemData, "icon_play_audio");
sprNode.on("click", () => { sprNode.on("click", async () => {
if(this.submitted) { if(this.submitted) {
return; return;
} }
let audioClip = asyncLoadRemote(contentData.audio_url); // 如果当前正在播放音频 则停止音频
if(this.currentAudioPlay != null) {
cc.audioEngine.stop(this.currentAudioPlay);
}
let audioClip = await asyncLoadRemote(contentData.audio_url);
// 需要判断音频是否存在 // 需要判断音频是否存在
if(audioClip) { if(audioClip) {
this.currentAudioPlay = cc.audioEngine.play(audioClip, false, 0.8); this.currentAudioPlay = cc.audioEngine.play(audioClip, false, 0.8);
cc.audioEngine.setFinishCallback(this.currentAudioPlay, () => { cc.audioEngine.setFinishCallback(audioClip, () => {
this.currentAudioPlay = null; this.currentAudioPlay = null;
}); });
} }
...@@ -580,16 +593,29 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -580,16 +593,29 @@ export default class SceneComponent extends MyCocosSceneComponent {
}; };
// 生成一个分数板 // 生成一个分数板
setScorePanel(data, totalScore, debugMode=false) { setScorePanel(data, debugMode=false) {
const rect = this.newRectNode(data, debugMode); const rect = this.newRectNode(data, debugMode);
const node = this.newTextNode(` /${totalScore}`); const node = this.newTextNode("");
const setScore = (score) => { const config = {
node.getComponent(cc.Label).string = `${score}/${totalScore}` node: null,
setScore: (score)=>{},
initTotalScore: (score)=>{}
} }
let totalScore = "";
config.setScore = (score) => {
node.getComponent(cc.Label).string = `${score}/${totalScore}`;
}
config.initTotalScore = (score) => {
totalScore = score;
node.getComponent(cc.Label).string = `/${totalScore}`;
}
config.node = node;
node.x = rect.width / 2; node.x = rect.width / 2;
node.y = rect.height / 2; node.y = rect.height / 2;
rect.addChild(node); rect.addChild(node);
return {node, setScore} return config
} }
// 新建矩形区域 // 新建矩形区域
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
...@@ -50,7 +50,7 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges { ...@@ -50,7 +50,7 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
color: '#8f3758' color: '#8f3758'
} }
@Input() @Input()
defaultItemType = 'text'; defaultItemType = 'rect';
@Input() @Input()
hotZoneImgSize = 190; hotZoneImgSize = 190;
......
...@@ -162,6 +162,7 @@ ...@@ -162,6 +162,7 @@
<div style="margin: 10px 10px;"> <div style="margin: 10px 10px;">
<span style="display: inline-block; text-align: right; width: 200px;">分数显示热区:</span> <span style="display: inline-block; text-align: right; width: 200px;">分数显示热区:</span>
<nz-select [(ngModel)]="it.linkHotZoneIndex" style="width: 100px;" (ngModelChange)="save()"> <nz-select [(ngModel)]="it.linkHotZoneIndex" style="width: 100px;" (ngModelChange)="save()">
<nz-option [nzValue]="-1" nzLabel="不显示"></nz-option>
<nz-option *ngFor="let itOPtion of item.hotZoneItemArr" [nzValue]="itOPtion.index" [nzLabel]="itOPtion.index + 1"></nz-option> <nz-option *ngFor="let itOPtion of item.hotZoneItemArr" [nzValue]="itOPtion.index" [nzLabel]="itOPtion.index + 1"></nz-option>
</nz-select> </nz-select>
<span style="margin-left: 10px;">热区名:{{item.hotZoneItemArr && item.hotZoneItemArr[it.linkHotZoneIndex] ? item.hotZoneItemArr[it.linkHotZoneIndex].itemName : "未配置"}}</span> <span style="margin-left: 10px;">热区名:{{item.hotZoneItemArr && item.hotZoneItemArr[it.linkHotZoneIndex] ? item.hotZoneItemArr[it.linkHotZoneIndex].itemName : "未配置"}}</span>
...@@ -177,6 +178,7 @@ ...@@ -177,6 +178,7 @@
<div style="margin: 10px 10px;"> <div style="margin: 10px 10px;">
<span style="display: inline-block; text-align: right; width: 100px;">总分显示:</span> <span style="display: inline-block; text-align: right; width: 100px;">总分显示:</span>
<nz-select [(ngModel)]="item.totalScoreHotZoneIndex" style="width: 100px;" (ngModelChange)="save()"> <nz-select [(ngModel)]="item.totalScoreHotZoneIndex" style="width: 100px;" (ngModelChange)="save()">
<nz-option [nzValue]="-1" nzLabel="不显示"></nz-option>
<nz-option *ngFor="let itOPtion of item.hotZoneItemArr" [nzValue]="itOPtion.index" [nzLabel]="itOPtion.index + 1"></nz-option> <nz-option *ngFor="let itOPtion of item.hotZoneItemArr" [nzValue]="itOPtion.index" [nzLabel]="itOPtion.index + 1"></nz-option>
</nz-select> </nz-select>
<span style="margin-left: 10px;">热区名:{{item.hotZoneItemArr && item.hotZoneItemArr[item.totalScoreHotZoneIndex] ? item.hotZoneItemArr[item.totalScoreHotZoneIndex].itemName : "未配置"}}</span> <span style="margin-left: 10px;">热区名:{{item.hotZoneItemArr && item.hotZoneItemArr[item.totalScoreHotZoneIndex] ? item.hotZoneItemArr[item.totalScoreHotZoneIndex].itemName : "未配置"}}</span>
...@@ -188,13 +190,6 @@ ...@@ -188,13 +190,6 @@
</nz-select> </nz-select>
<span style="margin-left: 10px;">热区名:{{item.hotZoneItemArr && item.hotZoneItemArr[item.submitHotZoneIndex] ? item.hotZoneItemArr[item.submitHotZoneIndex].itemName : "未配置"}}</span> <span style="margin-left: 10px;">热区名:{{item.hotZoneItemArr && item.hotZoneItemArr[item.submitHotZoneIndex] ? item.hotZoneItemArr[item.submitHotZoneIndex].itemName : "未配置"}}</span>
</div> </div>
<div style="margin: 10px 10px;">
<span style="display: inline-block; text-align: right; width: 100px;">重做按钮:</span>
<nz-select [(ngModel)]="item.replayHotZoneIndex" style="width: 100px;" (ngModelChange)="save()">
<nz-option *ngFor="let itOPtion of item.hotZoneItemArr" [nzValue]="itOPtion.index" [nzLabel]="itOPtion.index + 1"></nz-option>
</nz-select>
<span style="margin-left: 10px;">热区名:{{item.hotZoneItemArr && item.hotZoneItemArr[item.replayHotZoneIndex] ? item.hotZoneItemArr[item.replayHotZoneIndex].itemName : "未配置"}}</span>
</div>
<button nz-button nzType="dashed" (click)="addScoreConfig()" class="add-btn"> <button nz-button nzType="dashed" (click)="addScoreConfig()" class="add-btn">
<i nz-icon nzType="plus-circle" nzTheme="outline"></i> <i nz-icon nzType="plus-circle" nzTheme="outline"></i>
添加分数组配置 添加分数组配置
......
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