Commit 30e0d1ae authored by Tt's avatar Tt

除去点击事件

parent 6512c51f
...@@ -304,143 +304,144 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -304,143 +304,144 @@ export default class SceneComponent extends MyCocosSceneComponent {
private audioId: any; private audioId: any;
addPieceTouchEventListener(node: cc.Node, color) { addPieceTouchEventListener(node: cc.Node, color) {
node.on(cc.Node.EventType.TOUCH_START, (event: cc.Event.EventTouch) => {
const playerMe = this.allPlayerList.find(
(player) => player.uuid == this.playerId
);
if (playerMe.color != this._status.current) {
this.blinkPiece(node);
return;
}
if (this._status.current != color) {
this.blinkPiece(node);
return;
}
if (this._status.letter == "") {
this.blinkPiece(node);
return;
}
if (node["cantMove"]) {
this.blinkPiece(node);
return;
}
this.stopRollPiece(node);
node["touchStartPos"] = {
nodeX: node.x,
nodeY: node.y,
touchX: event.getLocation().x,
touchY: event.getLocation().y,
};
node.zIndex = 1;
this.showStars(node);
});
node.on(cc.Node.EventType.TOUCH_MOVE, (event: cc.Event.EventTouch) => {
const playerMe = this.allPlayerList.find(
(player) => player.uuid == this.playerId
);
if (playerMe.color != this._status.current) {
return;
}
if (this._status.current != color) {
return;
}
if (this._status.letter == "") {
return;
}
if (node["cantMove"]) {
return;
}
const pos = event.getLocation();
const touchStartPos = node["touchStartPos"];
const worldNodePos = node.parent.convertToWorldSpaceAR(
cc.v2(touchStartPos.nodeX, touchStartPos.nodeY)
);
const nodePos = node.parent.convertToNodeSpaceAR(
cc.v2(
worldNodePos.x + pos.x - touchStartPos.touchX,
worldNodePos.y + pos.y - touchStartPos.touchY
)
);
node.setPosition(nodePos);
});
node.on(cc.Node.EventType.TOUCH_END, async (event: cc.Event.EventTouch) => {
const playerMe = this.allPlayerList.find(
(player) => player.uuid == this.playerId
);
if (playerMe.color != this._status.current) {
return;
}
if (this._status.current != color) {
return;
}
if (this._status.letter == "") {
return;
}
if (node["cantMove"]) {
return;
}
node["cantMove"] = true;
if (this.checkNodeInRightBlock(node, color)) {
const idx = this.getNextRightIdx();
const playerMe = this.allPlayerList.find(
(player) => player.uuid == this.playerId
);
this.networkHelper.sendFrame({
type: "right",
idx: idx,
uuid: playerMe.uuid,
color: playerMe.color,
});
} else {
const playerMe = this.allPlayerList.find(
(player) => player.uuid == this.playerId
);
this.networkHelper.sendFrame({
type: "wrong",
uuid: playerMe.uuid,
color: playerMe.color,
});
}
});
node.on(cc.Node.EventType.TOUCH_CANCEL, async (event: cc.Event.EventTouch) => {
const playerMe = this.allPlayerList.find(
(player) => player.uuid == this.playerId
);
if (playerMe.color != this._status.current) {
return; return;
} // node.on(cc.Node.EventType.TOUCH_START, (event: cc.Event.EventTouch) => {
if (this._status.current != color) { // const playerMe = this.allPlayerList.find(
return; // (player) => player.uuid == this.playerId
} // );
if (this._status.letter == "") { // if (playerMe.color != this._status.current) {
return; // this.blinkPiece(node);
} // return;
if (node["cantMove"]) { // }
return; // if (this._status.current != color) {
} // this.blinkPiece(node);
node["cantMove"] = true; // return;
if (this.checkNodeInRightBlock(node, color)) { // }
const idx = this.getNextRightIdx(); // if (this._status.letter == "") {
const playerMe = this.allPlayerList.find( // this.blinkPiece(node);
(player) => player.uuid == this.playerId // return;
); // }
this.networkHelper.sendFrame({ // if (node["cantMove"]) {
type: "right", // this.blinkPiece(node);
idx: idx, // return;
uuid: playerMe.uuid, // }
color: playerMe.color, // this.stopRollPiece(node);
}); // node["touchStartPos"] = {
} else { // nodeX: node.x,
const playerMe = this.allPlayerList.find( // nodeY: node.y,
(player) => player.uuid == this.playerId // touchX: event.getLocation().x,
); // touchY: event.getLocation().y,
this.networkHelper.sendFrame({ // };
type: "wrong", // node.zIndex = 1;
uuid: playerMe.uuid, // this.showStars(node);
color: playerMe.color, // });
}); // node.on(cc.Node.EventType.TOUCH_MOVE, (event: cc.Event.EventTouch) => {
} // const playerMe = this.allPlayerList.find(
}); // (player) => player.uuid == this.playerId
// );
// if (playerMe.color != this._status.current) {
// return;
// }
// if (this._status.current != color) {
// return;
// }
// if (this._status.letter == "") {
// return;
// }
// if (node["cantMove"]) {
// return;
// }
// const pos = event.getLocation();
// const touchStartPos = node["touchStartPos"];
// const worldNodePos = node.parent.convertToWorldSpaceAR(
// cc.v2(touchStartPos.nodeX, touchStartPos.nodeY)
// );
// const nodePos = node.parent.convertToNodeSpaceAR(
// cc.v2(
// worldNodePos.x + pos.x - touchStartPos.touchX,
// worldNodePos.y + pos.y - touchStartPos.touchY
// )
// );
// node.setPosition(nodePos);
// });
// node.on(cc.Node.EventType.TOUCH_END, async (event: cc.Event.EventTouch) => {
// const playerMe = this.allPlayerList.find(
// (player) => player.uuid == this.playerId
// );
// if (playerMe.color != this._status.current) {
// return;
// }
// if (this._status.current != color) {
// return;
// }
// if (this._status.letter == "") {
// return;
// }
// if (node["cantMove"]) {
// return;
// }
// node["cantMove"] = true;
// if (this.checkNodeInRightBlock(node, color)) {
// const idx = this.getNextRightIdx();
// const playerMe = this.allPlayerList.find(
// (player) => player.uuid == this.playerId
// );
// this.networkHelper.sendFrame({
// type: "right",
// idx: idx,
// uuid: playerMe.uuid,
// color: playerMe.color,
// });
// } else {
// const playerMe = this.allPlayerList.find(
// (player) => player.uuid == this.playerId
// );
// this.networkHelper.sendFrame({
// type: "wrong",
// uuid: playerMe.uuid,
// color: playerMe.color,
// });
// }
// });
// node.on(cc.Node.EventType.TOUCH_CANCEL, async (event: cc.Event.EventTouch) => {
// const playerMe = this.allPlayerList.find(
// (player) => player.uuid == this.playerId
// );
// if (playerMe.color != this._status.current) {
// return;
// }
// if (this._status.current != color) {
// return;
// }
// if (this._status.letter == "") {
// return;
// }
// if (node["cantMove"]) {
// return;
// }
// node["cantMove"] = true;
// if (this.checkNodeInRightBlock(node, color)) {
// const idx = this.getNextRightIdx();
// const playerMe = this.allPlayerList.find(
// (player) => player.uuid == this.playerId
// );
// this.networkHelper.sendFrame({
// type: "right",
// idx: idx,
// uuid: playerMe.uuid,
// color: playerMe.color,
// });
// } else {
// const playerMe = this.allPlayerList.find(
// (player) => player.uuid == this.playerId
// );
// this.networkHelper.sendFrame({
// type: "wrong",
// uuid: playerMe.uuid,
// color: playerMe.color,
// });
// }
// });
} }
blinkPiece(node) { blinkPiece(node) {
......
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