| | |
| | | |
| | | |
| | | // batch move |
| | | if (this.selectedSprites && this.selectedSprites.length > 0) { |
| | | let batchMove = false; |
| | | let batchMoveStartPos = null; |
| | | Utils.spriteListBeMovable(this.selectedSprites, this.scale, this.activateMapEvent); |
| | | // if (this.selectedSprites && this.selectedSprites.length > 0) { |
| | | // let batchMove = false; |
| | | // let batchMoveStartPos = null; |
| | | |
| | | const batchMoving = (event) => { |
| | | if (batchMove) { |
| | | // offset move val |
| | | var mouseMovement = { |
| | | x: (event.global.x - batchMoveStartPos.x) / this.scale, |
| | | y: (event.global.y - batchMoveStartPos.y) / this.scale |
| | | }; |
| | | for (let sprite of this.selectedSprites) { |
| | | sprite.position.x = sprite.data.batchMoveStartPos.x + mouseMovement.x; |
| | | sprite.position.y = sprite.data.batchMoveStartPos.y + mouseMovement.y; |
| | | } |
| | | } |
| | | } |
| | | // const batchMoving = (event) => { |
| | | // if (batchMove) { |
| | | // // offset move val |
| | | // var mouseMovement = { |
| | | // x: (event.global.x - batchMoveStartPos.x) / this.scale, |
| | | // y: (event.global.y - batchMoveStartPos.y) / this.scale |
| | | // }; |
| | | // for (let sprite of this.selectedSprites) { |
| | | // sprite.position.x = sprite.data.batchMoveStartPos.x + mouseMovement.x; |
| | | // sprite.position.y = sprite.data.batchMoveStartPos.y + mouseMovement.y; |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | const batchMoveEnd = (event) => { |
| | | batchMove = false; |
| | | batchMoveStartPos = null; |
| | | this.selectedSprites.forEach(child => { |
| | | Utils.unMarkSprite(child); |
| | | }) |
| | | this.selectedSprites = []; |
| | | this.mapContainer.parent.off('mousedown'); |
| | | this.mapContainer.parent.off('mousemove'); |
| | | // const batchMoveEnd = (event) => { |
| | | // batchMove = false; |
| | | // batchMoveStartPos = null; |
| | | // this.selectedSprites.forEach(child => { |
| | | // Utils.unMarkSprite(child); |
| | | // }) |
| | | // this.selectedSprites = []; |
| | | // this.mapContainer.parent.off('mousedown'); |
| | | // this.mapContainer.parent.off('mousemove'); |
| | | |
| | | this.activateMapEvent(Utils.MapEvent.SELECTION_BOX); |
| | | } |
| | | // this.activateMapEvent(Utils.MapEvent.SELECTION_BOX); |
| | | // } |
| | | |
| | | const batchMoveStart = (event) => { |
| | | batchMoveStartPos = { x: event.data.global.clone().x, y: event.data.global.clone().y }; |
| | | this.selectedSprites.forEach(child => { |
| | | child.data.batchMoveStartPos = { x: child.position.x, y: child.position.y }; |
| | | }) |
| | | // const batchMoveStart = (event) => { |
| | | // batchMoveStartPos = { x: event.data.global.clone().x, y: event.data.global.clone().y }; |
| | | // this.selectedSprites.forEach(child => { |
| | | // child.data.batchMoveStartPos = { x: child.position.x, y: child.position.y }; |
| | | // }) |
| | | |
| | | batchMove = true; |
| | | this.mapContainer.parent.off('mousemove'); |
| | | this.mapContainer.parent.on('mousemove', batchMoving); |
| | | // batchMove = true; |
| | | // this.mapContainer.parent.off('mousemove'); |
| | | // this.mapContainer.parent.on('mousemove', batchMoving); |
| | | |
| | | this.mapContainer.parent.off('mouseup'); |
| | | this.mapContainer.parent.on('mouseup', batchMoveEnd); |
| | | } |
| | | // this.mapContainer.parent.off('mouseup'); |
| | | // this.mapContainer.parent.on('mouseup', batchMoveEnd); |
| | | // } |
| | | |
| | | this.mapContainer.parent.off('mousedown') |
| | | this.mapContainer.parent.on('mousedown', batchMoveStart); |
| | | } |
| | | // this.mapContainer.parent.off('mousedown') |
| | | // this.mapContainer.parent.on('mousedown', batchMoveStart); |
| | | // } |
| | | |
| | | |
| | | |