From 5c588ea56e3a04e3bbbc9fd362ed8f8d11ce6e53 Mon Sep 17 00:00:00 2001 From: k8w Date: Fri, 3 Dec 2021 13:59:00 +0800 Subject: [PATCH] update tsrpc-browser --- .../frontend/assets/scenes/GameScene/GameScene.ts | 2 +- .../frontend/assets/scripts/models/GameManager.ts | 10 ++-------- .../cocos-creator-multiplayer/frontend/package.json | 1 + 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/examples/cocos-creator-multiplayer/frontend/assets/scenes/GameScene/GameScene.ts b/examples/cocos-creator-multiplayer/frontend/assets/scenes/GameScene/GameScene.ts index ada0915..8356c1d 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/scenes/GameScene/GameScene.ts +++ b/examples/cocos-creator-multiplayer/frontend/assets/scenes/GameScene/GameScene.ts @@ -164,6 +164,6 @@ export class GameScene extends Component { // 显示坐标 —> 逻辑坐标 targetPos: { x: targetPos.x, y: targetPos.y }, targetTime: this.gameManager.state.now + gameConfig.arrowFlyTime - }) + } as any) } } \ No newline at end of file diff --git a/examples/cocos-creator-multiplayer/frontend/assets/scripts/models/GameManager.ts b/examples/cocos-creator-multiplayer/frontend/assets/scripts/models/GameManager.ts index 4546077..5dd50ca 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/scripts/models/GameManager.ts +++ b/examples/cocos-creator-multiplayer/frontend/assets/scripts/models/GameManager.ts @@ -23,7 +23,7 @@ export class GameManager { let client = this.client = new WsClient(serviceProto, { server: `ws://${location.hostname}:3000`, json: true, - logger: console + // logger: console });; client.listenMsg('server/Frame', msg => { this._onServerSync(msg) }); @@ -96,18 +96,12 @@ export class GameManager { return; } - console.log('sendClientInput', input, this.state.now); - let msg: MsgClientInput = { sn: ++this.lastSN, inputs: [input] } this.pendingInputMsgs.push(msg); - this.client.sendMsg('client/ClientInput', msg).then(v => { - if (!v.isSucc) { - console.error('xxxxxxxxxxxxxx', msg, v) - } - }); + this.client.sendMsg('client/ClientInput', msg); // 预测 this.gameSystem.applyInput({ diff --git a/examples/cocos-creator-multiplayer/frontend/package.json b/examples/cocos-creator-multiplayer/frontend/package.json index 8155950..fbe38b4 100644 --- a/examples/cocos-creator-multiplayer/frontend/package.json +++ b/examples/cocos-creator-multiplayer/frontend/package.json @@ -7,6 +7,7 @@ "version": "3.3.2" }, "dependencies": { + "tsrpc-base-client": "^1.2.3", "tsrpc-browser": "^3.1.3" } }