#
luxiaotao1123
2024-03-06 e29fffcbf6cbc426c459156f072ba2edac1716e5
#
1个文件已修改
32 ■■■■ 已修改文件
zy-asrs-flow/src/pages/map/player.js 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-flow/src/pages/map/player.js
@@ -33,8 +33,7 @@
            this.mapEvent = null;
        }
        this.mapEvent = (event) => {
            // left
            if (event.button === 0 && leftEvent) {
            if (leftEvent && event.button === 0) {
                switch (leftEvent) {
                    case Utils.MapEvent.SELECTION_BOX:
                        this.mapSelect(event);
@@ -43,8 +42,7 @@
                        break
                }
            }
            // right
            if (event.button === 2 && rightEvent) {
            if (rightEvent && event.button === 2) {
                switch (rightEvent) {
                    default:
                        break
@@ -56,11 +54,12 @@
    mapSelect = (event) => {
        let isSelecting = false;
        if (!this.selectionBox) {
            this.selectionBox = new PIXI.Graphics();
            this.app.stage.addChild(this.selectionBox);
        }
        const selectionBox = new PIXI.Graphics();
        this.app.stage.addChild(selectionBox);
        // start
        // select start pos
        const startPoint = new PIXI.Point();
        this.app.renderer.events.mapPositionToPoint(startPoint, event.clientX, event.clientY);
        let selectionStart = { x: startPoint.x, y: startPoint.y };
@@ -69,7 +68,7 @@
        const handleMouseMove = (event) => {
            if (isSelecting && !this.didClickSprite) {
                // end
                // select end pos
                const endPoint = new PIXI.Point();
                this.app.renderer.events.mapPositionToPoint(endPoint, event.clientX, event.clientY);
                const selectionEnd = { x: endPoint.x, y: endPoint.y }
@@ -77,11 +76,11 @@
                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.selectionBox.clear();
                this.selectionBox.lineStyle(2, 0xCCCCCC, 1);
                this.selectionBox.beginFill(0xCCCCCC, 0.2);
                this.selectionBox.drawRect(Math.min(selectionStart.x, selectionEnd.x), Math.min(selectionStart.y, selectionEnd.y), width, height);
                this.selectionBox.endFill();
            }
        }
@@ -89,6 +88,7 @@
        this.mapContainer.parent.on('mouseup', (event) => {
            if (isSelecting) {
                // sprite show style which be selected
                if (this.selectedSprites && this.selectedSprites.length > 0) {
                    this.selectedSprites.forEach(child => {
                        Utils.unMarkSprite(child);
@@ -97,13 +97,13 @@
                this.selectedSprites = [];
                this.mapContainer.children.forEach(child => {
                    if (Utils.isSpriteInSelectionBox(child, selectionBox)) {
                    if (Utils.isSpriteInSelectionBox(child, this.selectionBox)) {
                        this.selectedSprites.push(child);
                        Utils.markSprite(child);
                    }
                })
                isSelecting = false;
                selectionBox.clear();
                this.selectionBox.clear();
                // batch move