From 43fffc8b0d2ea88f379e8c72385bdfb42bb88108 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期六, 16 三月 2024 16:03:54 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/pages/map/utils.js |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/zy-asrs-flow/src/pages/map/utils.js b/zy-asrs-flow/src/pages/map/utils.js
index dfeee52..58fb2b2 100644
--- a/zy-asrs-flow/src/pages/map/utils.js
+++ b/zy-asrs-flow/src/pages/map/utils.js
@@ -344,7 +344,7 @@
                 mapContainer.addChild(sprite);
             }
         })
-        
+
     }).catch((error) => {
         console.error(error);
     })
@@ -404,4 +404,27 @@
         });
         childList = [];
     }
+}
+
+export const beCenter = (sprite) => {
+    if (!sprite || !app || !mapContainer) {
+        return;
+    }
+
+    mapContainer.scale.set(1);
+    mapContainer.position.set(0, 0);
+
+    let bounds = sprite.getBounds();
+    let centerPoint = {
+        x: bounds.x + bounds.width / 2,
+        y: bounds.y + bounds.height / 2
+    };
+
+    let targetPos = {
+        x: app.renderer.width / 3 - centerPoint.x * mapContainer.scale.x,
+        y: app.renderer.height / 3 - centerPoint.y * mapContainer.scale.y
+    };
+
+    new TWEEDLE.Tween(mapContainer.position).easing(TWEEDLE.Easing.Quadratic.Out)
+        .to(targetPos, 500).start();
 }
\ No newline at end of file

--
Gitblit v1.9.1