@vpmedia/phaser 1.0.30 → 1.0.32
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/README.md +1 -1
- package/dist/phaser.cjs +1 -1
- package/dist/phaser.cjs.LICENSE.txt +1 -1
- package/dist/phaser.cjs.map +1 -1
- package/dist/phaser.js +1 -1
- package/dist/phaser.js.LICENSE.txt +1 -1
- package/dist/phaser.js.map +1 -1
- package/package.json +1 -1
- package/src/index.js +2 -0
- package/src/phaser/core/sound_manager.js +5 -0
- package/src/phaser/core/sound_sprite.js +44 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vpmedia/phaser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"description": "@vpmedia/phaser is the modern ECMAScript port of the popular Phaser game engine v2.6.2",
|
|
5
5
|
"author": "Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)",
|
|
6
6
|
"license": "MIT",
|
package/src/index.js
CHANGED
|
@@ -27,6 +27,7 @@ import SceneManager from './phaser/core/scene_manager';
|
|
|
27
27
|
import Signal from './phaser/core/signal';
|
|
28
28
|
import SignalBinding from './phaser/core/signal_binding';
|
|
29
29
|
import Sound from './phaser/core/sound';
|
|
30
|
+
import SoundSprite from './phaser/core/sound_sprite';
|
|
30
31
|
import SoundManager from './phaser/core/sound_manager';
|
|
31
32
|
import Time from './phaser/core/time';
|
|
32
33
|
import Timer from './phaser/core/timer';
|
|
@@ -97,6 +98,7 @@ export {
|
|
|
97
98
|
Signal,
|
|
98
99
|
SignalBinding,
|
|
99
100
|
Sound,
|
|
101
|
+
SoundSprite,
|
|
100
102
|
SoundManager,
|
|
101
103
|
Time,
|
|
102
104
|
Timer,
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import ArraySet from './array_set';
|
|
7
7
|
import Signal from './signal';
|
|
8
8
|
import Sound from './sound';
|
|
9
|
+
import SoundSprite from './sound_sprite';
|
|
9
10
|
|
|
10
11
|
export default class {
|
|
11
12
|
|
|
@@ -221,6 +222,10 @@ export default class {
|
|
|
221
222
|
return sound;
|
|
222
223
|
}
|
|
223
224
|
|
|
225
|
+
addSprite(key) {
|
|
226
|
+
return new SoundSprite(this.game, key);
|
|
227
|
+
}
|
|
228
|
+
|
|
224
229
|
remove(sound) {
|
|
225
230
|
let i = this._sounds.length;
|
|
226
231
|
while (i) {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
|
+
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
|
+
*/
|
|
6
|
+
export default class {
|
|
7
|
+
constructor(game, key) {
|
|
8
|
+
this.game = game;
|
|
9
|
+
this.key = key;
|
|
10
|
+
this.config = this.game.cache.getJSON(key + '-audioatlas');
|
|
11
|
+
this.autoplayKey = null;
|
|
12
|
+
this.autoplay = false;
|
|
13
|
+
this.sounds = {};
|
|
14
|
+
for (let k in this.config.spritemap) {
|
|
15
|
+
const marker = this.config.spritemap[k];
|
|
16
|
+
const sound = this.game.sound.add(this.key);
|
|
17
|
+
sound.addMarker(k, marker.start, (marker.end - marker.start), null, marker.loop);
|
|
18
|
+
this.sounds[k] = sound;
|
|
19
|
+
}
|
|
20
|
+
if (this.config.autoplay) {
|
|
21
|
+
this.autoplayKey = this.config.autoplay;
|
|
22
|
+
this.play(this.autoplayKey);
|
|
23
|
+
this.autoplay = this.sounds[this.autoplayKey];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
play(marker, volume = 1) {
|
|
28
|
+
return this.sounds[marker].play(marker, null, volume);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
stop(marker) {
|
|
32
|
+
if (!marker) {
|
|
33
|
+
for (let key in this.sounds) {
|
|
34
|
+
this.sounds[key].stop();
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
this.sounds[marker].stop();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get(marker) {
|
|
42
|
+
return this.sounds[marker];
|
|
43
|
+
}
|
|
44
|
+
}
|