#
luxiaotao1123
2024-03-05 37921583eafff4a9cbad44c096dba516a1229d1f
#
2个文件已修改
42 ■■■■ 已修改文件
zy-asrs-flow/src/pages/map/player.js 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-flow/src/pages/map/utils.js 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-flow/src/pages/map/player.js
@@ -6,7 +6,7 @@
    constructor(dom, dark, didClickSprite) {
        this.darkModel = dark;
        this.didClickSprite = didClickSprite;
        this.didClickSprite = didClickSprite;   // not dynamic
        // init
        this.app = generatePixiApp(dark);
        dom.appendChild(this.app.view);
@@ -59,6 +59,12 @@
    }
    mapSelect = (event) => {
        if (this.selectedSprites && this.selectedSprites.length > 0) {
            this.selectedSprites.forEach(child => {
                Utils.unMarkSprite(child);
            })
        }
        this.selectedSprites = [];
        let isSelecting = false;
        const selectionBox = new PIXI.Graphics();
@@ -93,16 +99,18 @@
        this.app.view.addEventListener('mouseup', (event) => {
            if (isSelecting) {
                this.mapContainer.children.forEach(child => {
                    if (Utils.isSpriteInSelectionBox(child, selectionBox)) {
                        this.selectedSprites.push(child);
                        Utils.markSprite(child);
                    }
                })
                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);
                console.log('Selected Sprites:', this.selectedSprites);
            }
            this.app.view.removeEventListener('mousemove', handleMouseMove);
zy-asrs-flow/src/pages/map/utils.js
@@ -64,4 +64,22 @@
        }
    }
}
export const isSpriteInSelectionBox = (sprite, selectionBox) => {
    const spriteBounds = sprite.getBounds();
    const boxBounds = selectionBox.getBounds();
    return spriteBounds.x + spriteBounds.width > boxBounds.x
        && spriteBounds.x < boxBounds.x + boxBounds.width
        && spriteBounds.y + spriteBounds.height > boxBounds.y
        && spriteBounds.y < boxBounds.y + boxBounds.height;
}
export const markSprite = (sprite) => {
    sprite.alpha = 0.5;
}
export const unMarkSprite = (sprite) => {
    sprite.alpha = 1;
}