Commit 0cd07a05 authored by 李维's avatar 李维

修改连线组题型,可增加干扰项

parent dcaf5063
......@@ -89,6 +89,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
if(this.data.header_image_url) {
this._imageResList.push({ url: this.data.header_image_url });
}
if(this.data.hotZoneBgSliceList) {
this.data.hotZoneBgSliceList.forEach(sliceItem => {
if(sliceItem.image_url) {
this._imageResList.push({ url: sliceItem.image_url });
}
});
}
}
addPreloadAudio() {
......@@ -588,11 +595,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
const svContentSlicedBg = cc.find("Canvas/MainContent/ScorllView/view/content/slicedBg");
const pAll = [];
this.data.hotZoneBgSliceList.forEach((imgObj, index) => {
if(imgObj.image_url) {
pAll.push(new Promise((resovle, reject) =>{
cc.assetManager.loadRemote(imgObj.image_url, (err, img) => {
resovle(img);
});
}))
}
});
Promise.all(pAll).then(res=>{
......@@ -1319,6 +1328,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
if(currentConnectionList[index].linkedIndex == index) {
// 正确 返回分数
result.score += (option.score != null && !isNaN(Number(option.score))) ? Number(option.score) : 0;
} else if(currentConnectionList[index].rect == null && currentConnectionList[index].linkedIndex == -1) {
// 干扰项 没有被连接 正确 返回分数
result.score += (option.score != null && !isNaN(Number(option.score))) ? Number(option.score) : 0;
} else {
// 错误
detailItem.right = false;
......@@ -1332,7 +1344,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
contentData.contentList.forEach((option, index) => {
// 开始和结束点
const startHotZoneData = this.data.hotZoneItemArr[option.selectStartHotZoneIndex];
const startRect = this.newRectNode(startHotZoneData, layer_4, debugMode);
const noStartNode = startHotZoneData == undefined ? true : false;
const startRect = !noStartNode ? this.newRectNode(startHotZoneData, layer_4, debugMode) : null;
const endHotZoneData = this.data.hotZoneItemArr[option.selectEndHotZoneIndex];
const endRect = this.newRectNode(endHotZoneData, layer_5, debugMode);
......@@ -1342,8 +1355,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
iconStart.zIndex = layer_2;
iconEnd.zIndex = layer_2;
iconEndActive.zIndex = layer_2;
if(!noStartNode) {
iconStart.x = startRect.width / 2;
iconStart.y = startRect.height / 2;
}
iconEnd.x = endRect.width / 2;
iconEnd.y = endRect.height / 2;
iconEndActive.x = endRect.width / 2;
......@@ -1352,7 +1367,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
endRect.addChild(iconEnd);
endRect.addChild(iconEndActive);
if(!noStartNode) {
startRect.addChild(iconStart);
}
// 有些题需要在连接后 显示一个字符到指定区域 以下代码为实现
// 显示字符的节点
......@@ -1383,19 +1400,23 @@ export default class SceneComponent extends MyCocosSceneComponent {
getEndShowText: () => endShowText
})
let lineNode = null;
let ctx = null;
if(!noStartNode) {
// 新建节点 放置线条
const lineNode = new cc.Node();
lineNode = new cc.Node();
lineNode.name = 'connect_' + index;
startRect.addChild(lineNode)
const ctx = lineNode.addComponent(cc.Graphics);
ctx = lineNode.addComponent(cc.Graphics);
ctx.lineWidth = 4;
startRect.lineCtx = ctx;
}
// 临时存储连接所用 手指在移动时保存上一次命中的索引
let tempConnectResultIndex = -1;
// 手点击连线起点 发起连线
startRect.on(cc.Node.EventType.TOUCH_START, () => {
!noStartNode && startRect.on(cc.Node.EventType.TOUCH_START, () => {
if(this.submitted) {
return
}
......@@ -1410,7 +1431,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
})
// 松手 离开屏幕
startRect.on(cc.Node.EventType.TOUCH_CANCEL, () => {
!noStartNode && startRect.on(cc.Node.EventType.TOUCH_CANCEL, () => {
if(this.submitted) {
return
}
......@@ -1443,7 +1464,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
// console.log("触摸取消")
})
startRect.on(cc.Node.EventType.TOUCH_END, () => {
!noStartNode && startRect.on(cc.Node.EventType.TOUCH_END, () => {
if(this.submitted) {
return
}
......@@ -1476,7 +1497,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
// console.log("触摸结束")
})
startRect.on(cc.Node.EventType.TOUCH_MOVE, (e) => {
!noStartNode && startRect.on(cc.Node.EventType.TOUCH_MOVE, (e) => {
if(this.submitted) {
return
}
......
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