@urso/core 0.7.28 → 0.7.30

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urso/core",
3
- "version": "0.7.28",
3
+ "version": "0.7.30",
4
4
  "description": "HTML5 game engine",
5
5
  "main": "build/js/index.js",
6
6
  "author": "Megbrimef",
@@ -38,7 +38,7 @@ class ModulesLogicSounds {
38
38
  relaunch,
39
39
  loop,
40
40
  volume,
41
- };;
41
+ };
42
42
  });
43
43
  });
44
44
 
@@ -60,7 +60,7 @@ class SoundSprite {
60
60
 
61
61
  if (!soundState)
62
62
  return Urso.logger.error(`SoundSprite error: soundState for id '${id}' not found!`);
63
-
63
+
64
64
  if (!soundState.loop)
65
65
  soundState.id = null;
66
66
  });
@@ -74,7 +74,7 @@ class SoundSprite {
74
74
  return this._isAudioUnlocked;
75
75
  };
76
76
 
77
- play({ loop = false, volume = this._volume, relaunch = false, soundKey }) {
77
+ play({ soundKey, loop = false, volume = this._volume, relaunch = false, resetVolume = true }) {
78
78
  if (!this.canPlayCheck() || (this._soundsState[soundKey].id !== null && !relaunch))
79
79
  return false;
80
80
 
@@ -84,7 +84,9 @@ class SoundSprite {
84
84
 
85
85
  this.setRelaunch(soundKey, relaunch);
86
86
  this.setLoop(soundKey, loop);
87
- this.setVolume(soundKey, volume);
87
+
88
+ if (resetVolume)
89
+ this.setVolume({ soundKey, volume });
88
90
 
89
91
  return true;
90
92
  };
@@ -94,17 +96,17 @@ class SoundSprite {
94
96
  this._player.loop(loop, this._soundsState[soundKey].id);
95
97
  };
96
98
 
97
- setVolume(soundKey, volume = 1, saveVolumeState = true) {
99
+ setVolume({ soundKey, volume = 1, saveVolumeState = true }) {
98
100
  this._player.volume(volume, this._soundsState[soundKey].id);
99
-
100
- if(volume === 0) {
101
+
102
+ if (volume === 0) {
101
103
  this._changeSoundMute(true, soundKey);
102
104
  return;
103
- }else if(this._soundsState[soundKey]._muted) {
105
+ } else if (this._soundsState[soundKey]._muted) {
104
106
  this._changeSoundMute(false, soundKey);
105
107
  }
106
108
 
107
- if(saveVolumeState) {
109
+ if (saveVolumeState) {
108
110
  this._soundsState[soundKey].volume = volume;
109
111
  }
110
112
  };
@@ -123,7 +125,7 @@ class SoundSprite {
123
125
  this._player._volume = this._totalVolume;
124
126
  soundKeys.forEach(soundKey => {
125
127
  const soundVolume = this._soundsState[soundKey].volume * this._totalVolume;
126
- this.setVolume(soundKey, soundVolume, false);
128
+ this.setVolume({ soundKey, volume: soundVolume, saveVolumeState: false });
127
129
  });
128
130
  }
129
131
 
@@ -161,7 +163,7 @@ class SoundSprite {
161
163
  };
162
164
 
163
165
  _stopPrevFade(soundKey) {
164
- if(this._fadeTweens[soundKey]) {
166
+ if (this._fadeTweens[soundKey]) {
165
167
  this._fadeTweens[soundKey].kill();
166
168
  }
167
169
 
@@ -173,18 +175,18 @@ class SoundSprite {
173
175
  const delta = fadeTo - fadeFrom;
174
176
 
175
177
  const onUpdate = () => {
176
- const volume = (fadeFrom + (delta * this._fadeTweens[soundKey].ratio)) * this._totalVolume;
177
- this.setVolume(soundKey, volume);
178
+ const volume = (fadeFrom + (delta * this._fadeTweens[soundKey].ratio)) * this._totalVolume;
179
+ this.setVolume({ soundKey, volume });
178
180
  };
179
181
 
180
182
  this._fadeTweens[soundKey] = gsap.to({}, fadeDuration / 1000, { onUpdate });
181
183
  }
182
184
 
183
185
  fade({ fadeTo = 1, fadeDuration = 200, startSound = false, soundKey, ...others }) {
184
- if(startSound) {
186
+ if (startSound) {
185
187
  this.play({ ...others, soundKey });
186
188
  }
187
- if(this._soundsState[soundKey].id === null) {
189
+ if (this._soundsState[soundKey].id === null) {
188
190
  return;
189
191
  }
190
192