Commit 30e0d1ae authored by Tt's avatar Tt

除去点击事件

parent 6512c51f
......@@ -304,143 +304,144 @@ export default class SceneComponent extends MyCocosSceneComponent {
private audioId: any;
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;
}
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,
});
}
});
return;
// 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;
// }
// 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) {
......
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