From 5695ab2c72b2d50c50fdf4a5639572e9090379c9 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 04 三月 2024 17:14:42 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/pages/map/player.js |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 56 insertions(+), 1 deletions(-)

diff --git a/zy-asrs-flow/src/pages/map/player.js b/zy-asrs-flow/src/pages/map/player.js
index 4b5a39b..55784c0 100644
--- a/zy-asrs-flow/src/pages/map/player.js
+++ b/zy-asrs-flow/src/pages/map/player.js
@@ -22,7 +22,11 @@
 
         // func
         this.app.view.addEventListener('mousedown', (event) => {
-            // 鍙抽敭
+            // left
+            if (event.button === 0) {
+                this.mapSelect(event);
+            }
+            // right
             if (event.button === 2) {
                 this.mapPan(event);
             }
@@ -32,6 +36,57 @@
         this.appTicker();
     }
 
+    mapSelect = (event) => {
+        let isSelecting = false;
+
+        const selectionBox = new PIXI.Graphics();
+        this.app.stage.addChild(selectionBox);
+
+        // start
+        const startPoint = new PIXI.Point();
+        this.app.renderer.events.mapPositionToPoint(startPoint, event.clientX, event.clientY);
+        let selectionStart = { x: startPoint.x, y: startPoint.y };
+
+        isSelecting = true;
+
+        this.app.view.addEventListener('mousemove', (event) => {
+            console.log(1);
+            if (isSelecting) {
+
+                // end
+                const endPoint = new PIXI.Point();
+                this.app.renderer.events.mapPositionToPoint(endPoint, event.clientX, event.clientY);
+                const selectionEnd = { x: endPoint.x, y: endPoint.y }
+
+                const width = Math.abs(selectionEnd.x - selectionStart.x);
+                const height = Math.abs(selectionEnd.y - selectionStart.y);
+
+                selectionBox.clear();
+                selectionBox.lineStyle(2, 0xCCCCCC, 1);
+                selectionBox.beginFill(0xCCCCCC, 0.2);
+                selectionBox.drawRect(Math.min(selectionStart.x, selectionEnd.x), Math.min(selectionStart.y, selectionEnd.y), width, height);
+                selectionBox.endFill();
+            }
+        });
+
+        this.app.view.addEventListener('mouseup', (event) => {
+            if (isSelecting) {
+                isSelecting = false;
+                selectionBox.clear();
+
+                // const selectedSprites = this.mapContainer.children.filter(sprite => {
+                //     const spriteBounds = sprite.getBounds();
+                //     const boxBounds = new PIXI.Rectangle(Math.min(selectionStart.x, event.clientX), Math.min(selectionStart.y, event.clientY), Math.abs(event.clientX - selectionStart.x), Math.abs(event.clientY - selectionStart.y));
+                //     return spriteBounds.contains(boxBounds.x, boxBounds.y) && spriteBounds.contains(boxBounds.x + boxBounds.width, boxBounds.y + boxBounds.height);
+                // });
+
+                // console.log('Selected Sprites:', selectedSprites);
+            }
+
+            this.app.view.removeEventListener('mousemove'); 
+        });
+    }
+
     activateMapScale = () => {
         this.app.view.addEventListener('wheel', (event) => {
             event.preventDefault();

--
Gitblit v1.9.1