林旭祥 hace 3 semanas
padre
commit
f1b9cb40fd
Se han modificado 1 ficheros con 17 adiciones y 15 borrados
  1. 17 15
      src/views/game/components/fruit.vue

+ 17 - 15
src/views/game/components/fruit.vue

@@ -965,6 +965,8 @@ class MainScene extends Phaser.Scene {
 
     // 更新刀光
     this.blade.update();
+    this.leftBlade.update();
+    this.rightBlade.update();
 
     // 检查水果碰撞
     if (this.sandia && this.sandia.getSprite() && this.sandia.getSprite().active && !this.start) {
@@ -976,25 +978,23 @@ class MainScene extends Phaser.Scene {
       );
     }
 
-    // 分别更新左右手刀光
-    this.leftBlade.update();
-    this.rightBlade.update();
-
     // 分别检测左右手刀光与水果的碰撞
     if (this.sandia && this.sandia.getSprite() && !this.start) {
       // 右手碰撞检测
       this.rightBlade.checkCollide(
         this.sandia.getSprite(),
-        () => this.startGame()
+        () => {
+          this.startGame()
+        }
       );
       // 左手碰撞检测(可选:允许左手也能启动游戏)
       this.leftBlade.checkCollide(
         this.sandia.getSprite(),
-        () => this.startGame()
+        () => {
+          this.startGame()
+        }
       );
     }
-
-
   }
 
   homeGroupAnim() {
@@ -1316,6 +1316,7 @@ class PlayScene extends Phaser.Scene {
   bestAnim() {
     this.best = this.add.image(-100, 52, 'best');
     this.best.setOrigin(0, 0);
+    this.best.setScale(scaleRatio.value);
     this.tweens.add({
       targets: this.best,
       x: 5,
@@ -1325,11 +1326,12 @@ class PlayScene extends Phaser.Scene {
   }
 
   scoreTextAnim() {
-    this.scoreText = this.add.bitmapText(-100, 40, 'number', this.score.toString(), 32);
+    this.scoreText = this.add.bitmapText(-100, 20, 'number', this.score.toString(), 40);
     this.scoreText.setOrigin(0, 0);
+    this.scoreText.setScale(scaleRatio.value);
     this.tweens.add({
       targets: this.scoreText,
-      x: 75,
+      x: 150,
       duration: 300,
       ease: 'Sine.InOut'
     });
@@ -1343,10 +1345,10 @@ class PlayScene extends Phaser.Scene {
     this.xxx = this.add.image(49, 0, 'xxx');
 
     this.xxxGroup.add([this.x, this.xx, this.xxx]);
-
+    this.xxxGroup.setScale(scaleRatio.value);
     this.tweens.add({
       targets: this.xxxGroup,
-      x: width - 86,
+      x: width - 170,
       duration: 300,
       ease: 'Sine.InOut'
     });
@@ -1577,7 +1579,7 @@ class PlayScene extends Phaser.Scene {
     removeObj.destroy();
     const newObj = this.add.sprite(removeObj.x, removeObj.y, addKey);
     newObj.setOrigin(0, 0);
-    newObj.setScale(0);
+    newObj.setScale(scaleRatio.value);
     this.xxxGroup.add(newObj);
 
     this.tweens.add({
@@ -1696,7 +1698,7 @@ onBeforeMount(() => {
 
 // 初始化游戏
 onMounted(() => {
-    clientObj.value = {
+  clientObj.value = {
     width: document.documentElement.clientWidth,
     height: document.documentElement.clientHeight,
   }
@@ -1712,7 +1714,7 @@ onMounted(() => {
   mathTool.init();
 
   // 创建游戏实例
-  game = new Phaser.Game({
+  const game: any = new Phaser.Game({
     type: Phaser.CANVAS,
     width: width,
     height: height,