| | |
| | | mapContainer = param; |
| | | } |
| | | |
| | | export const MapEvent = Object.freeze({ |
| | | SELECTION_BOX: Symbol.for(0), |
| | | PAN: Symbol.for(1), |
| | | }) |
| | | |
| | | export const getRealPosition = (x, y, mapContainer) => { |
| | | const rect = app.view.getBoundingClientRect(); |
| | | return { |
| | |
| | | sprite.eventMode = 'static'; |
| | | } |
| | | |
| | | export const beMovable = (sprite) => { |
| | | export const beMovable = (sprite, setDidClickSprite) => { |
| | | sprite.off('pointerup'); |
| | | sprite.off('pointerdown'); |
| | | sprite.off('click'); |
| | |
| | | |
| | | let dragTarget; |
| | | function onDragStart(event) { |
| | | setDidClickSprite(true); |
| | | dragTarget = event.currentTarget; |
| | | mapContainer.parent.off('pointermove'); |
| | | mapContainer.parent.on('pointermove', onDragMove, dragTarget); |
| | |
| | | |
| | | function onDragEnd() { |
| | | if (dragTarget) { |
| | | setDidClickSprite(false); |
| | | this.parent.off('pointermove'); |
| | | dragTarget.alpha = 1; |
| | | dragTarget = null; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | 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; |
| | | } |