X Tutup
Skip to content

Commit b5778dd

Browse files
committed
Bug fixes.
1 parent be7f4d8 commit b5778dd

File tree

7 files changed

+53
-25
lines changed

7 files changed

+53
-25
lines changed

src/common/conversations/spring.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const otherPenguinGoodbye = [
3232
{
3333
image: Animation.OtherPenguinDialog,
3434
sound: [Sound.Penguin1, Sound.Penguin2],
35-
line1: ['What can one small pengiun do...'],
35+
line1: ['What can one small penguin do...'],
3636
line2: ['Against the adversities of the Antarctic?'],
3737
},
3838
{

src/scenes/autumn_jetty.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,17 @@ export class AutumnJetty extends Phaser.Scene {
100100
runCallback(() => this.player.animator.playAnimation(Animation.PlayerSleep)),
101101
runCallback(() => this.player.disableUserInput()),
102102
runCallback(() => this.ui.showLetterbox()),
103+
runCallback(() => this.camera.zoom(2)),
103104
runCallback(() => {
104-
this.camera.zoom(2);
105-
106-
const music = getAudioSingleton(this, Sound.MusicAutumn).setVolume(0);
105+
getAudioSingleton(this, Sound.MusicAutumn).setVolume(0);
106+
}),
107+
wait(500),
108+
runCallback(() => {
109+
const music = getAudioSingleton(this, Sound.MusicAutumn);
107110
music.play();
108111
fadeAudioVolume(this, music, 0.4, 8000);
109112
}),
110-
wait(1000),
113+
wait(500),
111114
runCallback(() => this.ui.fadeIn(2000)),
112115
wait(4000),
113116
playAnimation(this.player.sprite, Animation.PlayerWakeUp),

src/scenes/spring_jetty.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,17 @@ export class SpringJetty extends Phaser.Scene {
108108
runCallback(() => this.player.animator.playAnimation(Animation.PlayerSleep)),
109109
runCallback(() => this.player.disableUserInput()),
110110
runCallback(() => this.ui.showLetterbox()),
111+
runCallback(() => this.camera.zoom(2)),
111112
runCallback(() => {
112-
this.camera.zoom(2);
113-
114-
const music = getAudioSingleton(this, Sound.MusicSpring).setVolume(0);
113+
getAudioSingleton(this, Sound.MusicSpring).setVolume(0);
114+
}),
115+
wait(500),
116+
runCallback(() => {
117+
const music = getAudioSingleton(this, Sound.MusicSpring);
115118
music.play();
116119
fadeAudioVolume(this, music, 0.4, 8000);
117120
}),
118-
wait(1000),
121+
wait(500),
119122
runCallback(() => this.ui.fadeIn(2000)),
120123
wait(4000),
121124
playAnimation(this.player.sprite, Animation.PlayerWakeUp),

src/scenes/spring_title.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,18 @@ export class SpringTitle extends Phaser.Scene {
4040

4141
sequence(this)
4242
.of([
43-
runCallback(() => this.ui.fadeIn(1000, 'Linear')),
43+
runCallback(() => {
44+
this.ui.fadeIn(1000, 'Linear');
45+
const wind = getWindAudio(this);
46+
wind.setVolume(0);
47+
}),
4448
wait(1000),
4549
runCallback(() => {
4650
this.typewriter.typewrite(`Prologue.`);
4751

4852
const wind = getWindAudio(this);
49-
wind.setVolume(0);
50-
fadeAudioVolume(this, wind, 0.1);
5153
wind.play();
54+
fadeAudioVolume(this, wind, 0.1);
5255
}),
5356
wait(() => this.typewriter.typewriteDuration()),
5457
wait(500),

src/scenes/summer_jetty.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,17 @@ export class SummerJetty extends Phaser.Scene {
7171
runCallback(() => player.animator.playAnimation(Animation.PlayerSleep)),
7272
runCallback(() => player.disableUserInput()),
7373
runCallback(() => ui(this).showLetterbox()),
74+
runCallback(() => cam.zoom(2)),
7475
runCallback(() => {
75-
cam.zoom(2);
76-
77-
const music = getAudioSingleton(this, Sound.MusicSummer).setVolume(0);
76+
getAudioSingleton(this, Sound.MusicSummer).setVolume(0);
77+
}),
78+
wait(500),
79+
runCallback(() => {
80+
const music = getAudioSingleton(this, Sound.MusicSummer);
7881
music.play();
7982
fadeAudioVolume(this, music, 0.4, 8000);
8083
}),
81-
wait(1000),
84+
wait(500),
8285
runCallback(() => ui(this).fadeIn(2000)),
8386
wait(4000),
8487
playAnimation(player.sprite, Animation.PlayerWakeUp),

src/scenes/winter_title.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,20 @@ export class WinterTitle extends Phaser.Scene {
4040

4141
sequence(this)
4242
.of([
43+
runCallback(() => {
44+
getAudioSingleton(this, Sound.MusicWinter).setVolume(0);
45+
}),
4346
runCallback(() => {
4447
cam.shake(2, 0, -1, 200);
45-
46-
const music = getAudioSingleton(this, Sound.MusicWinter).setVolume(0);
48+
}),
49+
runCallback(() => this.ui.fadeIn(1000, 'Linear')),
50+
wait(500),
51+
runCallback(() => {
52+
const music = getAudioSingleton(this, Sound.MusicWinter);
4753
music.play();
4854
fadeAudioVolume(this, music, 0.4, 3800);
4955
}),
50-
runCallback(() => this.ui.fadeIn(1000, 'Linear')),
51-
wait(1000),
56+
wait(500),
5257
runCallback(() => {
5358
this.ui.hideLetterbox();
5459

src/systems/audio/objects/spatial_audio.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { clamp, normalize } from 'common/utils/math';
22
import { debugDepth, isDebug } from 'systems/flags';
3+
import { runCallback, sequence, wait } from 'systems/sequence';
34

45
export class SpatialAudio extends Phaser.GameObjects.Container {
56
public sound: Phaser.Sound.WebAudioSound | Phaser.Sound.HTML5AudioSound | Phaser.Sound.NoAudioSound;
67

78
private graphics: Phaser.GameObjects.Graphics;
89

10+
private isDestroyed = false;
11+
912
constructor(
1013
scene: Phaser.Scene,
1114
key: string,
@@ -26,10 +29,6 @@ export class SpatialAudio extends Phaser.GameObjects.Container {
2629
this.graphics.setDepth(debugDepth()).fillStyle(0xff0000, 1).fillPoint(d.translateX, d.translateY, 2);
2730
}
2831

29-
if (!this.sound.isPlaying) {
30-
return;
31-
}
32-
3332
const camera = this.scene.cameras.main;
3433

3534
const distanceTo = new Phaser.Math.Vector2(
@@ -45,6 +44,8 @@ export class SpatialAudio extends Phaser.GameObjects.Container {
4544
}
4645

4746
public destroy(fromScene?: boolean): void {
47+
this.isDestroyed = true;
48+
4849
this.sound.destroy();
4950

5051
this.graphics.destroy();
@@ -89,7 +90,17 @@ export class SpatialAudio extends Phaser.GameObjects.Container {
8990
}
9091

9192
public play() {
92-
this.sound.isPaused ? this.sound.resume() : this.sound.play();
93+
sequence(this.scene)
94+
.of([
95+
wait(50),
96+
runCallback(() => {
97+
if (!this.isDestroyed) {
98+
this.sound.isPaused ? this.sound.resume() : this.sound.play();
99+
}
100+
}),
101+
])
102+
.start()
103+
.destroyWhenComplete();
93104

94105
return this;
95106
}

0 commit comments

Comments
 (0)
X Tutup