|
@@ -505,6 +505,11 @@ class Bomb {
|
|
}
|
|
}
|
|
|
|
|
|
explode(onWhite, onComplete) {
|
|
explode(onWhite, onComplete) {
|
|
|
|
+ // 播放炸弹爆炸音效
|
|
|
|
+ const boomSound = this.game.sound.add('boom');
|
|
|
|
+ boomSound.play({
|
|
|
|
+ volume: 0.7 // 炸弹音效可稍大,增强冲击力
|
|
|
|
+ });
|
|
const lights = [];
|
|
const lights = [];
|
|
const startDeg = Math.floor(Math.random() * 360);
|
|
const startDeg = Math.floor(Math.random() * 360);
|
|
|
|
|
|
@@ -584,7 +589,7 @@ class Bomb {
|
|
targets: light,
|
|
targets: light,
|
|
alpha: { from: 0, to: 1, from: 0 },
|
|
alpha: { from: 0, to: 1, from: 0 },
|
|
scale: { from: 1, to: 2 },
|
|
scale: { from: 1, to: 2 },
|
|
- duration: 50,
|
|
|
|
|
|
+ duration: 100,
|
|
onComplete: () => {
|
|
onComplete: () => {
|
|
light.destroy();
|
|
light.destroy();
|
|
playChainAnimations(index + 1);
|
|
playChainAnimations(index + 1);
|
|
@@ -614,27 +619,27 @@ class Bomb {
|
|
// 开始执行第一个灯光动画
|
|
// 开始执行第一个灯光动画
|
|
playChainAnimations(0);
|
|
playChainAnimations(0);
|
|
|
|
|
|
- // 新增:在爆炸动画开始后立即隐藏炸弹,动画结束后销毁
|
|
|
|
- this.sprite.visible = false; // 先隐藏视觉元素
|
|
|
|
|
|
+ // 新增:在爆炸动画开始后立即隐藏炸弹,动画结束后销毁
|
|
|
|
+ this.sprite.visible = false; // 先隐藏视觉元素
|
|
|
|
|
|
- // 在爆炸完成回调中销毁炸弹
|
|
|
|
- const originalOnComplete = onComplete;
|
|
|
|
- onComplete = () => {
|
|
|
|
- // 销毁炸弹容器及其内部所有元素
|
|
|
|
- if (this.sprite) {
|
|
|
|
- this.sprite.destroy();
|
|
|
|
- }
|
|
|
|
- if (this.bombEmit) {
|
|
|
|
- this.bombEmit.destroy();
|
|
|
|
- }
|
|
|
|
- if (this.bombSmoke) {
|
|
|
|
- this.bombSmoke.destroy();
|
|
|
|
- }
|
|
|
|
- // 执行原有的完成回调
|
|
|
|
- if (typeof originalOnComplete === 'function') {
|
|
|
|
- originalOnComplete();
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+ // 在爆炸完成回调中销毁炸弹
|
|
|
|
+ const originalOnComplete = onComplete;
|
|
|
|
+ onComplete = () => {
|
|
|
|
+ // 销毁炸弹容器及其内部所有元素
|
|
|
|
+ if (this.sprite) {
|
|
|
|
+ this.sprite.destroy();
|
|
|
|
+ }
|
|
|
|
+ if (this.bombEmit) {
|
|
|
|
+ this.bombEmit.destroy();
|
|
|
|
+ }
|
|
|
|
+ if (this.bombSmoke) {
|
|
|
|
+ this.bombSmoke.destroy();
|
|
|
|
+ }
|
|
|
|
+ // 执行原有的完成回调
|
|
|
|
+ if (typeof originalOnComplete === 'function') {
|
|
|
|
+ originalOnComplete();
|
|
|
|
+ }
|
|
|
|
+ };
|
|
}
|
|
}
|
|
getSprite() {
|
|
getSprite() {
|
|
return this.sprite;
|
|
return this.sprite;
|
|
@@ -693,6 +698,13 @@ class Fruit {
|
|
transform.getY(0, 0)
|
|
transform.getY(0, 0)
|
|
);
|
|
);
|
|
|
|
|
|
|
|
+ // 播放切割音效
|
|
|
|
+ if (shouldEmit) { // 仅在需要发射粒子时播放(即有效切割时)
|
|
|
|
+ const splatterSound = this.game.sound.add('splatter');
|
|
|
|
+ splatterSound.play({
|
|
|
|
+ volume: 0.5 // 可调节音量,范围0-1
|
|
|
|
+ });
|
|
|
|
+ }
|
|
// 1. 计算切割方向的垂直向量(用于分离力)
|
|
// 1. 计算切割方向的垂直向量(用于分离力)
|
|
// 刀刃角度转弧度
|
|
// 刀刃角度转弧度
|
|
const rad = Phaser.Math.DegToRad(deg);
|
|
const rad = Phaser.Math.DegToRad(deg);
|
|
@@ -997,6 +1009,9 @@ class PreloadScene extends Phaser.Scene {
|
|
this.load.image('xxx', 'static/images/fruit/xxx.png');
|
|
this.load.image('xxx', 'static/images/fruit/xxx.png');
|
|
this.load.image('xxxf', 'static/images/fruit/xxxf.png');
|
|
this.load.image('xxxf', 'static/images/fruit/xxxf.png');
|
|
this.load.bitmapFont('number', 'static/images/fruit/bitmapFont.png', 'static/images/fruit/bitmapFont.xml');
|
|
this.load.bitmapFont('number', 'static/images/fruit/bitmapFont.png', 'static/images/fruit/bitmapFont.xml');
|
|
|
|
+ this.load.audio('splatter', 'static/images/fruit/splatter.mp3');
|
|
|
|
+ this.load.audio('boom', 'static/images/fruit/boom.mp3');
|
|
|
|
+ this.load.audio('throw', 'static/images/fruit/throw.mp3');
|
|
}
|
|
}
|
|
|
|
|
|
create() {
|
|
create() {
|
|
@@ -1155,6 +1170,12 @@ class MainScene extends Phaser.Scene {
|
|
|
|
|
|
this.start = true; // 先禁用立即切换
|
|
this.start = true; // 先禁用立即切换
|
|
const deg = this.blade.collideDeg();
|
|
const deg = this.blade.collideDeg();
|
|
|
|
+ // 播放初始西瓜切割音效
|
|
|
|
+ const splatterSound = this.sound.add('splatter');
|
|
|
|
+ splatterSound.play({
|
|
|
|
+ volume: 0.5 // 与普通水果切割音量保持一致
|
|
|
|
+ });
|
|
|
|
+
|
|
this.sandia.half(deg); // 切开西瓜,生成两半
|
|
this.sandia.half(deg); // 切开西瓜,生成两半
|
|
|
|
|
|
// 延迟1秒(1000ms)后再切换场景,等待动画展示
|
|
// 延迟1秒(1000ms)后再切换场景,等待动画展示
|
|
@@ -1557,7 +1578,7 @@ class PlayScene extends Phaser.Scene {
|
|
const startY = camera.y;
|
|
const startY = camera.y;
|
|
|
|
|
|
// 震动持续时间(ms)
|
|
// 震动持续时间(ms)
|
|
- const duration = 500;
|
|
|
|
|
|
+ const duration = 2000;
|
|
// 震动强度
|
|
// 震动强度
|
|
const intensity = 8;
|
|
const intensity = 8;
|
|
// 震动频率控制
|
|
// 震动频率控制
|