#
luxiaotao1123
2024-03-04 5695ab2c72b2d50c50fdf4a5639572e9090379c9
#
1个文件已修改
57 ■■■■■ 已修改文件
zy-asrs-flow/src/pages/map/player.js 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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();