Skip to content

Commit 0dd2339

Browse files
Merge pull request #116 from SpringRoll/feature/187532395-CreateJS-SpringRoll-Listeners
Feature/187532395 - CreateJS SpringRoll listeners
2 parents a50c34f + 5ae21cb commit 0dd2339

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
- Phaser: Updated feature list and state listeners to follow a standardized set
2121

2222
- CreateJS: Updated SpringRoll to 2.6.0
23+
- CreateJS: Updated feature list and state listeners to follow a standardized set
2324

2425

2526
## [1.3.1] - 2023-03-28

src/game.js

+28-20
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,22 @@ export class Game
99
{
1010
this.width = width;
1111
this.height = height;
12+
this.sfxVolume = 1;
13+
1214
this.app = new Application(
1315
{
1416
features:
1517
{
16-
sfx: true
18+
captions: true,
19+
sound: true,
20+
soundVolume: true,
21+
vo: true,
22+
voVolume: true,
23+
music: true,
24+
musicVolume: true,
25+
sfx: true,
26+
sfxVolume: true,
27+
1728
}
1829
});
1930

@@ -28,47 +39,44 @@ export class Game
2839
callback: this.resize
2940
});
3041

31-
// Subscribe to required springroll States.
42+
// Listen for container events from the application.
43+
// wait for the app to be ready, then set the new scene
44+
this.app.state.ready.subscribe(() =>
45+
{
46+
this.app.state.scene.value = new TitleScene(this);
47+
});
48+
3249
this.app.state.pause.subscribe((value) =>
3350
{
3451
this.isPaused = value;
3552
});
36-
53+
this.app.state.captionsMuted.subscribe(result =>
54+
{
55+
console.log('captionsMuted: ', result);
56+
});
3757
this.app.state.soundVolume.subscribe((value) =>
3858
{
39-
// set master volume
59+
// set main volume
4060
createjs.Sound.volume = value;
4161
});
42-
43-
this.sfxVolume = 1;
44-
this.app.state.sfxVolume.subscribe((value) =>
62+
this.app.state.voVolume.subscribe(result =>
4563
{
46-
this.sfxVolume = value;
64+
console.log('voVolume: ', result);
4765
});
4866
this.app.state.musicVolume.subscribe(result =>
4967
{
5068
console.log('musicVolume: ', result);
5169
});
52-
this.app.state.voVolume.subscribe(result =>
53-
{
54-
console.log('voVolume: ', result);
55-
});
56-
this.app.state.captionsMuted.subscribe(result =>
70+
this.app.state.sfxVolume.subscribe((value) =>
5771
{
58-
console.log('captionsMuted: ', result);
72+
this.sfxVolume = value;
5973
});
6074

6175
// add an extra state property for storying the current scene. Whenever the scene is changed, this class
6276
// will swap out the container attached to the stage
6377
this.app.state.scene = new Property(null);
6478
this.app.state.scene.subscribe(this.onChangeScene.bind(this));
6579

66-
// wait for the app to be ready, then set the new scene
67-
this.app.state.ready.subscribe(() =>
68-
{
69-
this.app.state.scene.value = new TitleScene(this);
70-
});
71-
7280
// Set Ticker
7381
createjs.Ticker.framerate = 60;
7482
createjs.Ticker.timingMode = createjs.Ticker.RAF_SYNCHED;

0 commit comments

Comments
 (0)