Commit 3f4f7cff authored by 范雪寒's avatar 范雪寒

fix: 连点导致的报错问题

parent 176a5498
...@@ -35,7 +35,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -35,7 +35,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
onLoadEnd() { onLoadEnd() {
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考 // TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this.log('onLoadEnd'); this.log("onLoadEnd");
this.initData(); this.initData();
this.initView(); this.initView();
this.initListener(); this.initListener();
...@@ -343,6 +343,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -343,6 +343,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
blinkPiece(node) { blinkPiece(node) {
if (node['rightTween']) {
return;
}
node.stopAllActions(); node.stopAllActions();
cc.tween(node) cc.tween(node)
.set({ scale: 1 }) .set({ scale: 1 })
...@@ -483,10 +486,12 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -483,10 +486,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
piece.zIndex = 1; piece.zIndex = 1;
this.showStars(piece); this.showStars(piece);
piece['rightTween'] = true;
await asyncTweenTo(piece, 1, { await asyncTweenTo(piece, 1, {
x: rightBlock.x + offsetX[color], x: rightBlock.x + offsetX[color],
y: rightBlock.y + offsetY[color], y: rightBlock.y + offsetY[color],
}); });
piece['rightTween'] = false;
for (let i = 0; i < 20; i++) { for (let i = 0; i < 20; i++) {
const star = cc.instantiate(cc.find("nodes/star")); const star = cc.instantiate(cc.find("nodes/star"));
...@@ -528,7 +533,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -528,7 +533,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
console.log(status); console.log(status);
this._status = JSON.parse(JSON.stringify(status)); this._status = JSON.parse(JSON.stringify(status));
} else { } else {
console.log('喵喵喵'); console.log("喵喵喵");
} }
const playerMe = this.allPlayerList.find( const playerMe = this.allPlayerList.find(
(player) => player.uuid == this.playerId (player) => player.uuid == this.playerId
...@@ -580,10 +585,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -580,10 +585,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
changeSide() { changeSide() {
if (this._status.current == "Red") { if (this._status.current == "Red") {
this._status.current = "Blue"; this._status.current = "Blue";
console.log('changeSide Blue'); console.log("changeSide Blue");
} else { } else {
this._status.current = "Red"; this._status.current = "Red";
console.log('changeSide Red'); console.log("changeSide Red");
} }
} }
...@@ -631,7 +636,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -631,7 +636,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
cc.log("playerLeave" + JSON.stringify(event)); cc.log("playerLeave" + JSON.stringify(event));
}); });
this.networkHelper.on("playerOffLine", (event) => { this.networkHelper.on("playerOffLine", (event) => {
cc.find('Canvas/bg/PlayerOffLineLayer').active = true; cc.find("Canvas/bg/PlayerOffLineLayer").active = true;
this.networkHelper.leaveRoom(); this.networkHelper.leaveRoom();
this.log("playerOffLine" + JSON.stringify(event)); this.log("playerOffLine" + JSON.stringify(event));
}); });
...@@ -709,7 +714,13 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -709,7 +714,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
console.log(rightBlock); console.log(rightBlock);
const idx = this.getNextRightIdx(); const idx = this.getNextRightIdx();
console.log(idx); console.log(idx);
const pieceRed = cc.find("Canvas/bg/chessBoard/pieceRed");
const pieceBlue = cc.find("Canvas/bg/chessBoard/pieceBlue");
pieceRed["cantMove"] = false;
pieceBlue["cantMove"] = false;
await this.pieceFindRightBlock(rightBlock, idx); await this.pieceFindRightBlock(rightBlock, idx);
pieceRed["cantMove"] = true;
pieceBlue["cantMove"] = true;
this._status.letter = ""; this._status.letter = "";
this.changeSide(); this.changeSide();
this.updateStatus(); this.updateStatus();
......
...@@ -23,7 +23,8 @@ export class AI { ...@@ -23,7 +23,8 @@ export class AI {
} else if (event.type == "SERVER_playerRoll") { } else if (event.type == "SERVER_playerRoll") {
this._status.letter = event.letter; this._status.letter = event.letter;
if (this.playerData.color == this._status.current) { if (this.playerData.color == this._status.current) {
await asyncDelay(Math.random() * 3 + 12); // await asyncDelay(Math.random() * 3 + 12);
await asyncDelay(15);
} }
} else if (event.type == "SERVER_playerRight") { } else if (event.type == "SERVER_playerRight") {
this._status.letter = ""; this._status.letter = "";
......
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