|
@@ -40,11 +40,11 @@
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<!-- 倒计时 -->
|
|
<!-- 倒计时 -->
|
|
- <div v-if="currentScene === 'countdown'" class="daoju">
|
|
|
|
|
|
+ <!-- <div v-if="currentScene === 'countdown'" class="daoju">
|
|
<div class="daojishibox">
|
|
<div class="daojishibox">
|
|
<div class="daojishinum">{{ countdownNum }}</div>
|
|
<div class="daojishinum">{{ countdownNum }}</div>
|
|
</div>
|
|
</div>
|
|
- </div>
|
|
|
|
|
|
+ </div> -->
|
|
|
|
|
|
<!-- 游戏结束 -->
|
|
<!-- 游戏结束 -->
|
|
<div v-if="currentScene === 'gameover'" class="gameend">
|
|
<div v-if="currentScene === 'gameover'" class="gameend">
|
|
@@ -95,7 +95,7 @@ const { clientObj, boxes, proportion, myThrow, myTimer, direction } = toRefs(dat
|
|
// 游戏状态管理
|
|
// 游戏状态管理
|
|
const currentScene = ref('start');
|
|
const currentScene = ref('start');
|
|
const showRules = ref(false);
|
|
const showRules = ref(false);
|
|
-const countdownNum = ref(3);
|
|
|
|
|
|
+// const countdownNum = ref(3);
|
|
const score = ref(0);
|
|
const score = ref(0);
|
|
const game = ref(null);
|
|
const game = ref(null);
|
|
const gameConfig = ref(null);
|
|
const gameConfig = ref(null);
|
|
@@ -193,7 +193,7 @@ const initGame = () => {
|
|
// restartGame();
|
|
// restartGame();
|
|
emit('confirmExit', { type: 2, area: props.currentGameArea });
|
|
emit('confirmExit', { type: 2, area: props.currentGameArea });
|
|
}
|
|
}
|
|
- }, 5000)
|
|
|
|
|
|
+ }, 500)
|
|
});
|
|
});
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
if (currentScene.value === 'start') {
|
|
if (currentScene.value === 'start') {
|
|
@@ -373,7 +373,7 @@ class GameScene extends Phaser.Scene {
|
|
//this.player = this.physics.add.sprite(clientObj.value.width / 2, clientObj.value.height - 100, 'playerAnim');
|
|
//this.player = this.physics.add.sprite(clientObj.value.width / 2, clientObj.value.height - 100, 'playerAnim');
|
|
this.player = this.physics.add.sprite(direction.value + 46, clientObj.value.height - 100, 'playerAnim');
|
|
this.player = this.physics.add.sprite(direction.value + 46, clientObj.value.height - 100, 'playerAnim');
|
|
this.player.setCollideWorldBounds(true);
|
|
this.player.setCollideWorldBounds(true);
|
|
- this.player.setScale(2.5);
|
|
|
|
|
|
+ this.player.setScale(2);
|
|
this.player.lives = this.lives;
|
|
this.player.lives = this.lives;
|
|
this.player.setDepth(9);
|
|
this.player.setDepth(9);
|
|
|
|
|
|
@@ -496,7 +496,7 @@ class GameScene extends Phaser.Scene {
|
|
spawnObstacle() {
|
|
spawnObstacle() {
|
|
const x = Phaser.Math.Between(30, clientObj.value.width - 30);
|
|
const x = Phaser.Math.Between(30, clientObj.value.width - 30);
|
|
const obstacle = this.physics.add.sprite(x, -50, 'pile');
|
|
const obstacle = this.physics.add.sprite(x, -50, 'pile');
|
|
- obstacle.setScale(2.5);
|
|
|
|
|
|
+ obstacle.setScale(2);
|
|
// 降低速度(从原来的this.speed * this.acceleration * 10调整为)
|
|
// 降低速度(从原来的this.speed * this.acceleration * 10调整为)
|
|
obstacle.setVelocityY(this.speed * this.acceleration * 12); // 速度减半
|
|
obstacle.setVelocityY(this.speed * this.acceleration * 12); // 速度减半
|
|
obstacle.setDepth(8);
|
|
obstacle.setDepth(8);
|
|
@@ -540,7 +540,7 @@ class GameScene extends Phaser.Scene {
|
|
// powerUp.type = 'broom';
|
|
// powerUp.type = 'broom';
|
|
// }
|
|
// }
|
|
|
|
|
|
- powerUp.setScale(2.5);
|
|
|
|
|
|
+ powerUp.setScale(2);
|
|
// 降低道具速度(从原来的this.speed * this.acceleration * 8调整为)
|
|
// 降低道具速度(从原来的this.speed * this.acceleration * 8调整为)
|
|
powerUp.setVelocityY(this.speed * this.acceleration * 12); // 速度降低
|
|
powerUp.setVelocityY(this.speed * this.acceleration * 12); // 速度降低
|
|
powerUp.setDepth(8);
|
|
powerUp.setDepth(8);
|
|
@@ -703,7 +703,7 @@ class GameScene extends Phaser.Scene {
|
|
|
|
|
|
// 创建球门
|
|
// 创建球门
|
|
this.goal = this.physics.add.sprite(clientObj.value.width / 2, 100, 'goal');
|
|
this.goal = this.physics.add.sprite(clientObj.value.width / 2, 100, 'goal');
|
|
- this.goal.setScale(2.5);
|
|
|
|
|
|
+ this.goal.setScale(2);
|
|
this.goal.setImmovable(true);
|
|
this.goal.setImmovable(true);
|
|
this.goal.setDepth(5);
|
|
this.goal.setDepth(5);
|
|
|
|
|
|
@@ -1127,27 +1127,36 @@ class GameScene extends Phaser.Scene {
|
|
|
|
|
|
// 游戏控制函数
|
|
// 游戏控制函数
|
|
const startGame = () => {
|
|
const startGame = () => {
|
|
- currentScene.value = 'countdown';
|
|
|
|
-
|
|
|
|
- // 倒计时
|
|
|
|
- currentScene.value = 'countdown';
|
|
|
|
- let count = 3;
|
|
|
|
- const countdownInterval = setInterval(() => {
|
|
|
|
- count--;
|
|
|
|
- countdownNum.value = count;
|
|
|
|
-
|
|
|
|
- if (count <= 0) {
|
|
|
|
- clearInterval(countdownInterval);
|
|
|
|
- currentScene.value = 'game';
|
|
|
|
- // 通知游戏开始
|
|
|
|
- if (game.value) {
|
|
|
|
- const gameScene = game.value.scene.getScene('GameScene');
|
|
|
|
- if (gameScene) {
|
|
|
|
- gameScene.startGame();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 倒计时
|
|
|
|
+ // currentScene.value = 'countdown';
|
|
|
|
+ // let count = 3;
|
|
|
|
+ // const countdownInterval = setInterval(() => {
|
|
|
|
+ // count--;
|
|
|
|
+ // countdownNum.value = count;
|
|
|
|
+
|
|
|
|
+ // if (count <= 0) {
|
|
|
|
+ // clearInterval(countdownInterval);
|
|
|
|
+ // currentScene.value = 'game';
|
|
|
|
+ // // 通知游戏开始
|
|
|
|
+ // if (game.value) {
|
|
|
|
+ // const gameScene = game.value.scene.getScene('GameScene');
|
|
|
|
+ // if (gameScene) {
|
|
|
|
+ // gameScene.startGame();
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }, 1000);
|
|
|
|
+
|
|
|
|
+ currentScene.value = 'game';
|
|
|
|
+ // 通知游戏开始
|
|
|
|
+ if (game.value) {
|
|
|
|
+ const gameScene = game.value.scene.getScene('GameScene');
|
|
|
|
+ if (gameScene) {
|
|
|
|
+ gameScene.startGame();
|
|
}
|
|
}
|
|
- }, 1000);
|
|
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
const continueGame = () => {
|
|
const continueGame = () => {
|
|
@@ -1172,7 +1181,7 @@ const restartGame = () => {
|
|
// 2. 重置全局状态
|
|
// 2. 重置全局状态
|
|
score.value = 0;
|
|
score.value = 0;
|
|
currentScene.value = 'start';
|
|
currentScene.value = 'start';
|
|
- countdownNum.value = 3;
|
|
|
|
|
|
+ // countdownNum.value = 3;
|
|
|
|
|
|
// 3. 初始化新游戏
|
|
// 3. 初始化新游戏
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|