Commit 94b84879 authored by 李维's avatar 李维

禁止连线题有两道题连到同一个选项的操作

parent 31ab18fe
...@@ -1389,6 +1389,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -1389,6 +1389,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
startRect.addChild(lineNode) startRect.addChild(lineNode)
const ctx = lineNode.addComponent(cc.Graphics); const ctx = lineNode.addComponent(cc.Graphics);
ctx.lineWidth = 4; ctx.lineWidth = 4;
startRect.lineCtx = ctx;
// 临时存储连接所用 手指在移动时保存上一次命中的索引 // 临时存储连接所用 手指在移动时保存上一次命中的索引
let tempConnectResultIndex = -1; let tempConnectResultIndex = -1;
...@@ -1420,16 +1421,28 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -1420,16 +1421,28 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 隐藏所有终点高亮 // 隐藏所有终点高亮
this.setActiveEndPointsByUID(false, uid); this.setActiveEndPointsByUID(false, uid);
// 如果当前连线已经有连接过 则找到上次的连接索引 清掉
const oldLinkedIndex = currentConnectionList.findIndex(ccl=>ccl.linkedIndex == index);
if(oldLinkedIndex >= 0) {
currentConnectionList[oldLinkedIndex].linkedIndex = -1;
}
// 把命中的节点的连接索引更新 // 把命中的节点的连接索引更新
if(tempConnectResultIndex >= 0) { if(tempConnectResultIndex >= 0) {
// 当前被连接的点如果已经有起点连接过 则清掉之前的连线
if(currentConnectionList[tempConnectResultIndex].linkedIndex >= 0) {
// 命中节点已经连过线了
currentConnectionList[tempConnectResultIndex].linkedRect.lineCtx.clear();
}
currentConnectionList[tempConnectResultIndex].linkedIndex = index; currentConnectionList[tempConnectResultIndex].linkedIndex = index;
currentConnectionList[tempConnectResultIndex].linkedRect = startRect;
tempConnectResultIndex = -1; tempConnectResultIndex = -1;
} else { } else {
ctx.clear() ctx.clear();
} }
// console.log("触摸取消") // console.log("触摸取消")
}) })
startRect.on(cc.Node.EventType.TOUCH_END, () => { startRect.on(cc.Node.EventType.TOUCH_END, () => {
if(this.submitted) { if(this.submitted) {
return return
...@@ -1441,14 +1454,25 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -1441,14 +1454,25 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 隐藏所有终点高亮 // 隐藏所有终点高亮
this.setActiveEndPointsByUID(false, uid); this.setActiveEndPointsByUID(false, uid);
// 如果当前连线已经有连接过 则找到上次的连接索引 清掉
const oldLinkedIndex = currentConnectionList.findIndex(ccl=>ccl.linkedIndex == index);
if(oldLinkedIndex >= 0) {
currentConnectionList[oldLinkedIndex].linkedIndex = -1;
}
// 把命中的节点的连接索引更新 // 把命中的节点的连接索引更新
if(tempConnectResultIndex >= 0) { if(tempConnectResultIndex >= 0) {
// 当前被连接的点如果已经有起点连接过 则清掉之前的连线
if(currentConnectionList[tempConnectResultIndex].linkedIndex >= 0) {
// 命中节点已经连过线了
currentConnectionList[tempConnectResultIndex].linkedRect.lineCtx.clear();
}
currentConnectionList[tempConnectResultIndex].linkedIndex = index; currentConnectionList[tempConnectResultIndex].linkedIndex = index;
currentConnectionList[tempConnectResultIndex].linkedRect = startRect;
tempConnectResultIndex = -1; tempConnectResultIndex = -1;
} else { } else {
ctx.clear() ctx.clear()
} }
// console.log("触摸结束") // console.log("触摸结束")
}) })
......
This diff is collapsed.
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