Skip to content

Commit c66a457

Browse files
Merge pull request #110 from SpringRoll/feature/187532396-springroll-listeners
Feature/187532396 - Phaser template Springroll listeners
2 parents ca6ce80 + b0c2e3c commit c66a457

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

src/SpringrollGame.js

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,37 +42,52 @@ class SpringrollGame {
4242
// Flag any additional features. See https://github.com/SpringRoll/SpringRoll/tree/master/src
4343
this.application = new Application({
4444
features: {
45-
pause: true,
46-
soundVolume:true,
47-
musicVolume: true,
45+
captions: true,
46+
sound: true,
47+
soundVolume: true,
48+
vo: true,
4849
voVolume: true,
50+
music: true,
51+
musicVolume: true,
52+
sfx: true,
53+
sfxVolume: true,
4954
}
5055
});
5156

5257
// Listen for container events from the application.
58+
this.application.state.ready.subscribe(this.onApplicationReady.bind(this));
5359
this.application.state.pause.subscribe(this.onApplicationPause.bind(this));
54-
this.application.state.soundVolume.subscribe(this.onMasterVolumeChange.bind(this));
55-
this.application.state.musicVolume.subscribe(result => {
56-
console.log('musicVolume: ', result);
60+
61+
this.application.state.captionsMuted.subscribe(result => {
62+
console.log('captionsMuted: ', result);
5763
});
64+
this.application.state.soundVolume.subscribe(this.onMainVolumeChange.bind(this));
5865
this.application.state.voVolume.subscribe(result => {
5966
console.log('voVolume: ', result);
6067
});
61-
this.application.state.captionsMuted.subscribe(result => {
62-
console.log('captionsMuted: ', result);
68+
this.application.state.musicVolume.subscribe(result => {
69+
console.log('musicVolume: ', result);
6370
});
71+
this.application.state.sfxVolume.subscribe(result => {
72+
console.log('sfxVolume: ', result);
73+
});
74+
}
75+
76+
onApplicationReady() {
77+
console.log('The app is ready. All plugins have finished their setup and preload calls');
6478
}
6579

66-
onApplicationPause(value) {
67-
if (value) {
80+
onApplicationPause(isPaused) {
81+
console.log('Is the game paused?', isPaused);
82+
if (isPaused) {
6883
this.game.scene.pause(SCENE.GAME);
6984
}
7085
else {
7186
this.game.scene.resume(SCENE.GAME);
7287
}
7388
}
7489

75-
onMasterVolumeChange(value) {
90+
onMainVolumeChange(value) {
7691
this.game.sound.volume = value;
7792
}
7893

0 commit comments

Comments
 (0)