| | |
| | | |
| | | 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); |
| | |
| | | } |
| | | |
| | | 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(); |
| | |
| | | |
| | | 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); |