From 2fb6fd6bea5bd60651131780fbd7a838e632a803 Mon Sep 17 00:00:00 2001 From: genxium Date: Tue, 31 Jan 2023 23:11:46 +0800 Subject: [PATCH] Updated CameraTracker. --- frontend/assets/scenes/offline_map.fire | 2 +- frontend/assets/scripts/CameraTracker.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/assets/scenes/offline_map.fire b/frontend/assets/scenes/offline_map.fire index 7d4d203..a0fe376 100644 --- a/frontend/assets/scenes/offline_map.fire +++ b/frontend/assets/scenes/offline_map.fire @@ -547,7 +547,7 @@ "array": [ 0, 0, - 210.53572189052173, + 209.73151519075364, 0, 0, 0, diff --git a/frontend/assets/scripts/CameraTracker.js b/frontend/assets/scripts/CameraTracker.js index 41fffb4..66fda31 100644 --- a/frontend/assets/scripts/CameraTracker.js +++ b/frontend/assets/scripts/CameraTracker.js @@ -29,6 +29,15 @@ cc.Class({ if (!selfPlayerRichInfo) return; const selfPlayerNode = selfPlayerRichInfo.node; if (!selfPlayerNode) return; - self.mapNode.setPosition(cc.v2().sub(selfPlayerNode.position)); + const dst = cc.v2().sub(selfPlayerNode.position); + const pDiff = dst.sub(self.mapNode.position); + const stepLength = dt * self.speed; + if (stepLength > pDiff.mag()) { + self.mapNode.setPosition(dst); + } else { + pDiff.normalizeSelf(); + const newMapPos = self.mapNode.position.add(pDiff.mul(dt * self.speed)); + self.mapNode.setPosition(newMapPos); + } } });