| | |
| | | this.getStartedTicker(); |
| | | } |
| | | |
| | | activateMapEvent = (leftEvent, rightEvent) => { |
| | | activateMapEvent = (eventType, mapModel) => { |
| | | if (this.mapEvent) { |
| | | this.mapContainer.parent.off('mousedown'); |
| | | this.mapEvent = null; |
| | |
| | | } |
| | | } |
| | | this.mapEvent = (event) => { |
| | | if (leftEvent && event.button === 0) { |
| | | switch (leftEvent) { |
| | | if (eventType && event.button === 0) { |
| | | switch (eventType) { |
| | | case Utils.MapEvent.SELECTION_BOX: |
| | | this.mapSelect(event); |
| | | this.mapSelect(event, mapModel); |
| | | break |
| | | default: |
| | | break |
| | | } |
| | | } |
| | | if (rightEvent && event.button === 2) { |
| | | switch (rightEvent) { |
| | | default: |
| | | break |
| | | } |
| | |
| | | this.mapContainer.parent.on('mousedown', this.mapEvent) |
| | | } |
| | | |
| | | mapSelect = (event) => { |
| | | mapSelect = (event, mapModel) => { |
| | | let isSelecting = false; |
| | | if (!this.selectionBox) { |
| | | this.selectionBox = new PIXI.Graphics(); |
| | |
| | | |
| | | // sprites batch move |
| | | Utils.spriteListBeMovable(this.selectedSprites, this.scale, () => { |
| | | this.activateMapEvent(Utils.MapEvent.SELECTION_BOX); |
| | | this.activateMapEvent(Utils.MapEvent.SELECTION_BOX, mapModel); |
| | | }); |
| | | |
| | | } |
| | |
| | | |
| | | showCoordinates = () => { |
| | | const coordinatesText = new PIXI.Text('{ x: 0, y: 0 }', { |
| | | fill: 0x000000, |
| | | fill: this.darkModel ? 0xffffff : 0x000000, |
| | | fontSize: 13, |
| | | fontFamily: 'MicrosoftYaHei', |
| | | fontWeight: 'bold', |
| | |
| | | } |
| | | |
| | | showGridlines = () => { |
| | | this.hideGridlines(); |
| | | if (!this.gridLineContainer) { |
| | | this.gridLineContainer = generatePixiContainer('gridLineContainer'); |
| | | this.app.stage.addChild(this.gridLineContainer); |
| | |
| | | if (!this.mapContainer || !this.app) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | this.mapContainer.scale.set(1); |
| | | this.mapContainer.position.set(0, 0); |
| | | if (this.mapContainer.children.length === 0) { |
| | |
| | | |
| | | function generatePixiApp(dark) { |
| | | const app = new PIXI.Application({ |
| | | background: dark ? '#f1f2f6' : '#f1f2f6', |
| | | background: dark ? '#2f3542' : '#f1f2f6', |
| | | antialias: true, |
| | | }) |
| | | app.stage.eventMode = 'static'; |