pixi-rainman-game-engine 0.3.23 → 0.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -56,7 +56,7 @@ export class RainMan {
56
56
  }
57
57
  }
58
58
  initLocalStorageSettings() {
59
- setIfDoesntExistInLocalStorage(LOCAL_STORAGE.hiResolution, true);
59
+ setIfDoesntExistInLocalStorage(LOCAL_STORAGE.hiResolution, false);
60
60
  setIfDoesntExistInLocalStorage(LOCAL_STORAGE.batterySaver, false);
61
61
  setIfDoesntExistInLocalStorage(LOCAL_STORAGE.volumeLevel, 100);
62
62
  setToLocalStorage(LOCAL_STORAGE.isSoundFxEnabled, true);
@@ -106,5 +106,11 @@ export declare class SoundManagerInstance implements SpeedAdapterInterface<Sound
106
106
  * @returns {void}
107
107
  */
108
108
  stop(soundName: SoundTrack): void;
109
+ /**
110
+ * Function that resumes sounds and music when game is back in focus.
111
+ * @public
112
+ * @returns {void}
113
+ */
114
+ resumeOnFocus(): Promise<void>;
109
115
  }
110
116
  export declare const SoundManager: SoundManagerInstance;
@@ -224,5 +224,29 @@ export class SoundManagerInstance {
224
224
  stop(soundName) {
225
225
  this.musicCatalogue.get(soundName)?.stop();
226
226
  }
227
+ /**
228
+ * Function that resumes sounds and music when game is back in focus.
229
+ * @public
230
+ * @returns {void}
231
+ */
232
+ async resumeOnFocus() {
233
+ const pixiSoundContext = sound.context;
234
+ const audioContext = pixiSoundContext.audioContext;
235
+ const state = audioContext.state;
236
+ if (state === "suspended" || state === "interrupted") {
237
+ try {
238
+ await sound.context.audioContext.resume();
239
+ }
240
+ catch (error) {
241
+ console.error("Could not resume audio");
242
+ }
243
+ const ambientMusic = this.musicCatalogue.get(RainMan.settingsStore.isFreeSpinsPlayEnabled ? "freeSpinsMusic" : "music");
244
+ if (ambientMusic !== undefined &&
245
+ ambientMusic.isPlaying !== true &&
246
+ RainMan.settingsStore.shouldPlayAmbientMusic) {
247
+ ambientMusic.resume();
248
+ }
249
+ }
250
+ }
227
251
  }
228
252
  export const SoundManager = SoundManagerInstance.getInstance();
@@ -32,7 +32,7 @@ export class SettingsStore {
32
32
  infinitySpinsEnabled = false;
33
33
  roundNumber = 0;
34
34
  reelSetId = 0;
35
- HiResolutionFlag = getFromLocalStorage(LOCAL_STORAGE.hiResolution, true);
35
+ HiResolutionFlag = getFromLocalStorage(LOCAL_STORAGE.hiResolution, false);
36
36
  batterySaverFlag = getFromLocalStorage(LOCAL_STORAGE.batterySaver, false);
37
37
  isGambleGameAvailable = true;
38
38
  isGambleGameActive = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixi-rainman-game-engine",
3
- "version": "0.3.23",
3
+ "version": "0.3.24",
4
4
  "description": "This repository contains all of the mechanics that used in rainman games.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "@pixi/filter-glow": "^5.2.1",
24
24
  "@pixi/layers": "^2.1.0",
25
25
  "@pixi/particle-emitter": "^5.0.8",
26
- "@pixi/sound": "^5.2.2",
26
+ "@pixi/sound": "5.2.3",
27
27
  "@tweenjs/tween.js": "18.6.4",
28
28
  "adaptive-scale": "^1.0.0",
29
29
  "i18next": "^23.10.1",