| | |
| | | } |
| | | } |
| | | |
| | | export const initSprite = (sprite) => { |
| | | export const initSprite = (sprite, type) => { |
| | | sprite.anchor.set(0.5); |
| | | sprite.cursor = 'pointer'; |
| | | sprite.eventMode = 'static'; |
| | | sprite.data = {}; |
| | | sprite.data = { |
| | | type: type |
| | | }; |
| | | } |
| | | |
| | | // sprite be movable from sprite click event |
| | |
| | | |
| | | export const showSelectedEffect = (sprite) => { |
| | | const { width, height } = sprite; |
| | | const scale = mapContainer.scale.x; |
| | | const scale = sprite.scale.x; |
| | | const sideLen = (Math.max(width, height) + 10) * scale; |
| | | const color = 0x273c75; |
| | | |
| | | effectHalfCircle = new PIXI.Graphics(); |
| | | effectHalfCircle.beginFill(color); |
| | | effectHalfCircle.lineStyle(2, color); |
| | | effectHalfCircle.lineStyle(2 * scale, color); |
| | | effectHalfCircle.arc(0, 0, sideLen, 0, Math.PI); |
| | | effectHalfCircle.endFill(); |
| | | effectHalfCircle.position.set(sprite.x, sprite.y); |
| | | effectHalfCircle.scale.set(1 / scale); |
| | | |
| | | effectRectangle = new PIXI.Graphics(); |
| | | effectRectangle.lineStyle(2, color, 1); |
| | | effectRectangle.drawRoundedRect(0, 0, sideLen, sideLen, 16); |
| | | effectRectangle.lineStyle(2 * scale, color, 1); |
| | | effectRectangle.drawRoundedRect(0, 0, sideLen, sideLen, 16 * scale); |
| | | effectRectangle.endFill(); |
| | | effectRectangle.mask = effectHalfCircle; |
| | | |