| | |
| | | |
| | | export default class Player { |
| | | |
| | | constructor(dom, dark) { |
| | | constructor(dom, dark, didClickSprite) { |
| | | this.darkModel = dark; |
| | | this.didClickSprite = didClickSprite; |
| | | // init |
| | | this.app = generatePixiApp(dark); |
| | | dom.appendChild(this.app.view); |
| | |
| | | |
| | | this.pan = false; // 平移 |
| | | |
| | | this.activateMapEvent(null, Utils.MapEvent.PAN) |
| | | this.activateMapEvent(null, Utils.MapEvent.PAN); |
| | | this.activateMapScale(); |
| | | this.showCoordinates(); |
| | | this.appTicker(); |
| | |
| | | |
| | | activateMapEvent = (leftEvent, rightEvent) => { |
| | | if (this.mapEvent) { |
| | | this.app.view.removeEventListener('mousemove', this.mapEvent); |
| | | this.app.view.removeEventListener('mousedown', this.mapEvent); |
| | | } |
| | | |
| | | this.mapEvent = (event) => { |
| | |
| | | } |
| | | |
| | | mapSelect = (event) => { |
| | | let that = this; |
| | | let isSelecting = false; |
| | | |
| | | const selectionBox = new PIXI.Graphics(); |
| | |
| | | |
| | | isSelecting = true; |
| | | |
| | | function handleMouseMove(event) { |
| | | if (isSelecting) { |
| | | const handleMouseMove = (event) => { |
| | | if (isSelecting && !this.didClickSprite) { |
| | | // end |
| | | const endPoint = new PIXI.Point(); |
| | | that.app.renderer.events.mapPositionToPoint(endPoint, event.clientX, event.clientY); |
| | | this.app.renderer.events.mapPositionToPoint(endPoint, event.clientX, event.clientY); |
| | | const selectionEnd = { x: endPoint.x, y: endPoint.y } |
| | | |
| | | const width = Math.abs(selectionEnd.x - selectionStart.x); |
| | |
| | | } |
| | | } |
| | | |
| | | updateDidClickSprite = (value) => { |
| | | this.didClickSprite = value; |
| | | } |
| | | |
| | | appTicker = () => { |
| | | TWEEDLE.Group.shared.update(); |
| | | } |