From 7dc0f27e6d92167fd1e826b29c2b14f64961d08e Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期四, 07 十一月 2024 09:56:45 +0800 Subject: [PATCH] # --- zy-acs-flow/src/map/player.js | 27 +++++++++++++++++++++++---- 1 files changed, 23 insertions(+), 4 deletions(-) diff --git a/zy-acs-flow/src/map/player.js b/zy-acs-flow/src/map/player.js index b5b60f9..506e6c0 100644 --- a/zy-acs-flow/src/map/player.js +++ b/zy-acs-flow/src/map/player.js @@ -1,7 +1,7 @@ import * as PIXI from 'pixi.js'; import * as TWEEDLE from 'tweedle.js'; import * as Tool from './tool'; -import star from '/public/img/map/star.png' +import star from '/img/map/star.png' export default class Player { @@ -228,6 +228,22 @@ }, 200).start(); } + rotateMap = () => { + const bounds = this.mapContainer.getLocalBounds(); + const centerX = bounds.x + bounds.width / 2; + const centerY = bounds.y + bounds.height / 2; + this.mapContainer.pivot.set(centerX, centerY); + this.mapContainer.position.set(this.app.renderer.width / 2, this.app.renderer.height / 2); + + const rotationIncrement = Math.PI / 2; // 90 degrees in radians + const newRotation = this.mapContainer.rotation + rotationIncrement; + + new TWEEDLE.Tween(this.mapContainer) + .to({ rotation: newRotation }, 300) + .easing(TWEEDLE.Easing.Quadratic.Out) + .start(); + } + showCoordinates = () => { this.coordinatesText = new PIXI.Text('{ x: 0, y: 0 }', { fill: this.themeMode === 'dark' ? 0xdddddd : 0x333333, @@ -376,9 +392,10 @@ } startupTicker = () => { - this.app.ticker.add((delta) => { + this.tweedle = (delta) => { TWEEDLE.Group.shared.update(); - }); + } + this.app.ticker.add(this.tweedle); } resize = (width, height) => { @@ -386,6 +403,8 @@ } destroy = () => { + TWEEDLE.Group.shared.removeAll(); + this.app.ticker.remove(this.tweedle); this.app.destroy(true, { children: true }); } @@ -406,7 +425,7 @@ }) app.stage.eventMode = 'static'; app.stage.hitArea = app.screen; - + app.view.addEventListener('contextmenu', (event) => { event.preventDefault(); }); -- Gitblit v1.9.1