From 99cc3bb108a9ced40b126778da8bbd34963549b5 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 10 十月 2024 10:52:10 +0800
Subject: [PATCH] #

---
 zy-acs-flow/src/map/player.js |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/zy-acs-flow/src/map/player.js b/zy-acs-flow/src/map/player.js
index 9b2124b..bb27b88 100644
--- a/zy-acs-flow/src/map/player.js
+++ b/zy-acs-flow/src/map/player.js
@@ -17,6 +17,7 @@
 
         this.activateMapScale();
         this.activateMapPan();
+        this.showCoordinates();
         this.startupTicker();
 
         const bunny = PIXI.Sprite.from('https://pixijs.com/assets/bunny.png');
@@ -226,6 +227,25 @@
             }, 200).start();
     }
 
+    showCoordinates = () => {
+        const coordinatesText = new PIXI.Text('{ x: 0, y: 0 }', {
+            fill: this.themeMode === 'dark' ? 0xffffff : 0x000000,
+            fontSize: 13,
+            fontFamily: 'MicrosoftYaHei',
+            fontWeight: 'bold',
+        });
+        coordinatesText.name = 'xyStr'
+        coordinatesText.position.set(10, 10);
+        this.app.stage.addChild(coordinatesText);
+
+        const mouseMoveInfoTextHandler = (event) => {
+            const mouseX = (event.clientX - this.mapContainer.position.x) / this.scale;
+            const mouseY = (event.clientY - this.mapContainer.position.y) / this.scale;
+            coordinatesText.text = `{ x: ${mouseX.toFixed(2)}, y: ${mouseY.toFixed(2)} }`;
+        };
+        this.app.view.addEventListener('mousemove', mouseMoveInfoTextHandler);
+    }
+
     showGridLines = () => {
         this.hideGridLines();
         if (!this.gridLineContainer) {
@@ -264,7 +284,6 @@
             this.gridLineContainer = null;
         }
     }
-
 
     startupTicker = () => {
         this.app.ticker.add((delta) => {

--
Gitblit v1.9.1