mirror of
http://junepve.top:3000/chicrobot/CINC.git
synced 2026-10-30 02:51:29 +08:00
feat(fog) 添加迷雾场景
This commit is contained in:
1 parent
556d576060
commit
c09770753f
4 files changed
+286
-3
No files matched your search
+28
-2
@@ -417,6 +417,13 @@ export default class MenuScene extends Phaser.Scene {
|
||||
// 添加开始按钮点击事件
|
||||
startClickArea.on('pointerdown', () => {
|
||||
console.log('Start game clicked');
|
||||
|
||||
// 清除所有与涟漪相关的延迟调用,避免场景切换后仍然执行
|
||||
this.rippleTimeouts.forEach(timeoutId => {
|
||||
clearTimeout(timeoutId);
|
||||
});
|
||||
this.rippleTimeouts = [];
|
||||
|
||||
// 添加进入场景前的过渡动画
|
||||
this.cameras.main.fadeOut(500, 0, 0, 0);
|
||||
this.cameras.main.once('camerafadeoutcomplete', () => {
|
||||
@@ -582,7 +589,10 @@ export default class MenuScene extends Phaser.Scene {
|
||||
for (let i = 0; i < rippleCount; i++) {
|
||||
// 随机延迟开始
|
||||
const timeoutId = setTimeout(() => {
|
||||
this.createSingleRipple(screenWidth, screenHeight);
|
||||
// 确保场景仍然存在且 rippleGroup 存在
|
||||
if (this.scene && this.rippleGroup) {
|
||||
this.createSingleRipple(screenWidth, screenHeight);
|
||||
}
|
||||
}, Phaser.Math.Between(0, 3000));
|
||||
|
||||
// 将timeout ID保存到数组中
|
||||
@@ -609,7 +619,7 @@ export default class MenuScene extends Phaser.Scene {
|
||||
// 延迟创建后续的涟漪层
|
||||
const timeoutId = setTimeout(() => {
|
||||
// 只有在雨天效果开启时,才创建新的涟漪
|
||||
if (this.isRainEnabled) {
|
||||
if (this.isRainEnabled && this.rippleGroup) {
|
||||
// 创建涟漪圆圈(只保留边框)
|
||||
const ripple = this.add.circle(
|
||||
x,
|
||||
@@ -662,4 +672,20 @@ export default class MenuScene extends Phaser.Scene {
|
||||
this.rippleTimeouts.push(timeoutId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 场景关闭时的清理工作
|
||||
*/
|
||||
shutdown() {
|
||||
// 清除所有与涟漪相关的延迟调用
|
||||
this.rippleTimeouts.forEach(timeoutId => {
|
||||
clearTimeout(timeoutId);
|
||||
});
|
||||
|
||||
// 清空timeout数组
|
||||
this.rippleTimeouts = [];
|
||||
|
||||
// 调用父类的shutdown方法
|
||||
super.shutdown();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user