Commit 3ec21225 authored by 李维's avatar 李维

暂时提交代码

未完成连线组
parent 8f2961c4
...@@ -117,9 +117,13 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -117,9 +117,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
isDestroy = false; isDestroy = false;
startTimestamp = null; startTimestamp = null;
isHistoryMode = false; // 历史记录模式
async onLoadEnd() { async onLoadEnd() {
// TODO 加载完成后的逻辑写在这里 // TODO 加载完成后的逻辑写在这里
console.log(this.data); console.log(this.data);
if(this.isHistoryMode) {
this.data = historyData.dataSaved;
}
this.disableScroll(); // 禁用页面滚动 this.disableScroll(); // 禁用页面滚动
this.initSize(); // 页面尺寸 this.initSize(); // 页面尺寸
this.initMiddleLayer(); // 中间层相关 this.initMiddleLayer(); // 中间层相关
...@@ -128,8 +132,11 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -128,8 +132,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.initVideoPlayerLayer(); // 视频播放层 this.initVideoPlayerLayer(); // 视频播放层
await this.initHotZoneBg(); // 初始化背景 await this.initHotZoneBg(); // 初始化背景
this.initSlicedHotZoneBg(); // 切片背景图 - 修复某些设备上背景图过长导致的黑屏 this.initSlicedHotZoneBg(); // 切片背景图 - 修复某些设备上背景图过长导致的黑屏
if(!this.isHistoryMode) {
this.initHotZoneItem(); // 初始化热区数据 this.initHotZoneItem(); // 初始化热区数据
// this.showHistory(); // 展示模式 } else {
this.showHistory(); // 展示模式
}
this.initScorePanel(); this.initScorePanel();
this.initActionButton(); this.initActionButton();
this.initScoreShow(); this.initScoreShow();
...@@ -810,7 +817,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -810,7 +817,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 显示历史做题记录 // 显示历史做题记录
showHistory() { showHistory() {
historyData.dataSaved.hotZoneConfigArr.forEach((configItem, index) => { this.data.hotZoneConfigArr.forEach((configItem, index) => {
const resultData = historyData.details.filter(item=>item.configIndex == index); const resultData = historyData.details.filter(item=>item.configIndex == index);
if(resultData.length == 0) { if(resultData.length == 0) {
return return
...@@ -844,6 +851,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -844,6 +851,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
case HOT_ZONE_CHECKBOX: case HOT_ZONE_CHECKBOX:
this.showCheckboxGroup(configItem, resultData); this.showCheckboxGroup(configItem, resultData);
break; break;
// 连线组
case CONNECTION:
this.showConnectionGroup(configItem, resultData);
break;
} }
}) })
...@@ -862,7 +873,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -862,7 +873,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.newDecorativeFrame(hotZoneItemData, layer_1, "#FFFFFF", "#6dbef6", debugMode); this.newDecorativeFrame(hotZoneItemData, layer_1, "#FFFFFF", "#6dbef6", debugMode);
const rect = this.newRectNode(hotZoneItemData, layer_4, debugMode); const rect = this.newRectNode(hotZoneItemData, layer_4, debugMode);
const historyItem = resultData.find(item=>item.contentIndex == index) const historyItem = resultData.find(item=>item.contentIndex == index)
console.log(historyItem)
const textShow = historyItem.currentSelectIndex ? configItem.selectOptionList[historyItem.currentSelectIndex].text : "" const textShow = historyItem.currentSelectIndex ? configItem.selectOptionList[historyItem.currentSelectIndex].text : ""
const inputLabel = this.newInputTextNode(textShow + "", 0); const inputLabel = this.newInputTextNode(textShow + "", 0);
inputLabel.x = rect.width / 2; inputLabel.x = rect.width / 2;
...@@ -911,11 +921,81 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -911,11 +921,81 @@ export default class SceneComponent extends MyCocosSceneComponent {
resultRect.addChild(errIcon); resultRect.addChild(errIcon);
} }
}) })
}
// 连线组 - 历史记录
showConnectionGroup(configItem, resultData) {
console.log(configItem, resultData)
const debugMode = false;
const resultIconShowData = this.data.hotZoneItemArr[configItem.linkResultShowHotZoneIndex];
const resultIconRect = this.newRectNode(resultIconShowData, layer_2, debugMode);
let allRight = true;
resultData[0].results.forEach(item => {
if(item.right == false) {
allRight = false
}
});
const errIcon = getSprNode("icon_answer_wrong");
const rightIcon = getSprNode("icon_answer_right");
// 图标太大 缩小一半
errIcon.scale = rightIcon.scale = 0.5;
// 显示在热区的中间
errIcon.x = rightIcon.x = resultIconRect.width / 2;
errIcon.y = rightIcon.y = resultIconRect.height / 2;
if(allRight) {
resultIconRect.addChild(rightIcon);
} else {
resultIconRect.addChild(errIcon);
}
resultData[0].results.forEach((resData, index) => {
const startHotZoneData = this.data.hotZoneItemArr[configItem.contentList[index].selectStartHotZoneIndex];
const startRect = this.newRectNode(startHotZoneData, layer_4, debugMode);
const endHotZoneData = this.data.hotZoneItemArr[configItem.contentList[resData.currentEndIndex].selectEndHotZoneIndex];
const endRect = this.newRectNode(endHotZoneData, layer_5, debugMode);
const iconStart = this.getSprNode("icon_connect_start");
const iconEnd = this.getSprNode("icon_connect_end");
iconStart.zIndex = layer_2;
iconEnd.zIndex = layer_2;
iconStart.x = startRect.width / 2;
iconStart.y = startRect.height / 2;
iconEnd.x = endRect.width / 2;
iconEnd.y = endRect.height / 2;
endRect.addChild(iconEnd);
startRect.addChild(iconStart);
const lineNode = new cc.Node();
lineNode.name = 'connect1_' + index;
startRect.addChild(lineNode)
const ctx = lineNode.addComponent(cc.Graphics);
ctx.lineWidth = 4;
const localPos = lineNode.parent.convertToNodeSpaceAR(endRect.parent.convertToWorldSpaceAR(cc.v2(endRect.x + endRect.width / 2, endRect.y + endRect.height / 2)));
// 清除上一次的痕迹
ctx.clear()
// 移动到当前开始节点的中心开始画线
ctx.moveTo(startRect.width / 2, startRect.height / 2);
// 终点坐标在上面已经计算好了 这里使用
ctx.lineTo(localPos.x, localPos.y);
// 画线
ctx.stroke();
});
} }
// 判断对错 - 历史记录 // 判断对错 - 历史记录
showRightOrWrongGroup(configItem, resultData) { showRightOrWrongGroup(configItem, resultData) {
console.log(configItem, resultData)
const debugMode = false; const debugMode = false;
const resultIconShowData = this.data.hotZoneItemArr[configItem.linkResultShowHotZoneIndex]; const resultIconShowData = this.data.hotZoneItemArr[configItem.linkResultShowHotZoneIndex];
const resultIconRect = this.newRectNode(resultIconShowData, layer_2, debugMode); const resultIconRect = this.newRectNode(resultIconShowData, layer_2, debugMode);
...@@ -986,7 +1066,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -986,7 +1066,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
showHistoryRadio(configItem, resultData) { showHistoryRadio(configItem, resultData) {
const debugMode = false; const debugMode = false;
const historyItem = resultData[0]; const historyItem = resultData[0];
const resultIconShowData = this.data.hotZoneItemArr[configItem.linkResultShowHotZoneIndex]; const resultIconShowData = this.data.hotZoneItemArr[configItem.linkResultShowHotZoneIndex];
const resultIconRect = this.newRectNode(resultIconShowData, layer_2, false); const resultIconRect = this.newRectNode(resultIconShowData, layer_2, false);
...@@ -996,7 +1075,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -996,7 +1075,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
configItem.contentList.forEach((option, index) => { configItem.contentList.forEach((option, index) => {
const hotZoneData = this.data.hotZoneItemArr[option.selectHotZoneIndex]; const hotZoneData = this.data.hotZoneItemArr[option.selectHotZoneIndex];
const rect = this.newRectNode(hotZoneData, layer_4, debugMode); const rect = this.newRectNode(hotZoneData, layer_4, debugMode);
// 创建 结果节点 颜色区域 和 边框 // 创建 结果节点 颜色区域 和 边框
const maskNode = this.newMaskRectNode(hotZoneData, layer_2, "#00000033"); const maskNode = this.newMaskRectNode(hotZoneData, layer_2, "#00000033");
const selLineNode = this.newOutlineNode(hotZoneData, layer_2, "#6dbef6"); const selLineNode = this.newOutlineNode(hotZoneData, layer_2, "#6dbef6");
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
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