@vpmedia/phaser 1.0.29 → 1.0.31

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": "@vpmedia/phaser",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
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
@@ -21,13 +21,13 @@ import InputTouch from './phaser/core/input_touch';
21
21
  import Loader from './phaser/core/loader';
22
22
  import GameLoopRAF from './phaser/core/raf';
23
23
  import GameLoopTO from './phaser/core/raf_to';
24
- import GameLoopFB from './phaser/core/raf_fb';
25
24
  import ScaleManager from './phaser/core/scale_manager';
26
25
  import Scene from './phaser/core/scene';
27
26
  import SceneManager from './phaser/core/scene_manager';
28
27
  import Signal from './phaser/core/signal';
29
28
  import SignalBinding from './phaser/core/signal_binding';
30
29
  import Sound from './phaser/core/sound';
30
+ import SoundSprite from './phaser/core/sound_sprite';
31
31
  import SoundManager from './phaser/core/sound_manager';
32
32
  import Time from './phaser/core/time';
33
33
  import Timer from './phaser/core/timer';
@@ -90,7 +90,6 @@ export {
90
90
  Loader,
91
91
  GameLoopRAF,
92
92
  GameLoopTO,
93
- GameLoopFB,
94
93
  MathUtils,
95
94
  StringUtils,
96
95
  ScaleManager,
@@ -99,6 +98,7 @@ export {
99
98
  Signal,
100
99
  SignalBinding,
101
100
  Sound,
101
+ SoundSprite,
102
102
  SoundManager,
103
103
  Time,
104
104
  Timer,
@@ -190,7 +190,6 @@ export default class {
190
190
 
191
191
  parseConfig(config) {
192
192
  /* game */
193
- this.parseConfigElement(config, 'isDestroyUnload', false);
194
193
  this.parseConfigElement(config, 'isSkipWindowFocus', false);
195
194
  this.parseConfigElement(config, 'forceSetTimeOut', false);
196
195
  this.parseConfigElement(config, 'lockRender', false);
@@ -214,10 +213,12 @@ export default class {
214
213
  // Clear the Canvas each frame before rendering the display list.
215
214
  // You can set this to `false` to gain some performance if your game always contains a background that completely fills the display.
216
215
  this.parseConfigElement(config, 'clearBeforeRender', true);
217
- // The Renderer this game will use. Either PowerGamer.Const.RENDER_AUTO, PowerGamer.Const.RENDER_CANVAS, PowerGamer.Const.RENDER_WEBGL
216
+ // The Renderer this game will use. Either Const.RENDER_AUTO, Const.RENDER_CANVAS, Const.RENDER_WEBGL
218
217
  this.parseConfigElement(config, 'renderType', RENDER_AUTO);
219
218
  // Force audio disabled
220
219
  this.parseConfigElement(config, 'isForceDisabledAudio', false);
220
+ // Sets the number of maximum parallel requests for the loaded (in case of HTTP/2 you can raise this)
221
+ this.parseConfigElement(config, 'maxParallelDownloads', 16);
221
222
  if (config.renderer) {
222
223
  this.config.renderType = config.renderer;
223
224
  }
@@ -34,10 +34,7 @@ export default class {
34
34
  this.onFileStart = new Signal();
35
35
  this.onFileComplete = new Signal();
36
36
  this.onFileError = new Signal();
37
- this.useXDomainRequest = false;
38
- this._warnedAboutXDomainRequest = false;
39
- this.enableParallel = true;
40
- this.maxParallelDownloads = 5;
37
+ this.maxParallelDownloads = this.game.config.maxParallelDownloads || 16;
41
38
  this._withSyncPointDepth = 0;
42
39
  this._fileList = [];
43
40
  this._flightQueue = [];
@@ -446,7 +443,7 @@ export default class {
446
443
  }
447
444
  // When true further non-pack file downloads are suppressed
448
445
  let syncblock = false;
449
- const inflightLimit = this.enableParallel ? Math.max(1, this.maxParallelDownloads) : 1;
446
+ const inflightLimit = this.maxParallelDownloads;
450
447
  for (let i = this._processingHead; i < this._fileList.length; i += 1) {
451
448
  const file = this._fileList[i];
452
449
  // Pack is fetched (ie. has data) and is currently at the start of the process queue.
@@ -569,10 +566,13 @@ export default class {
569
566
  this.video(file.key, file.urls ? file.urls : file.url);
570
567
  break;
571
568
  case "audio":
572
- this.audio(file.key, file.urls ? file.urls : file.url, file.autoDecode);
569
+ this.audio(file.key, file.urls ? file.urls : file.url);
573
570
  break;
574
571
  case "audiosprite":
575
- this.audioSprite(file.key, file.urls ? file.urls : file.url, file.jsonURL, file.jsonData, file.autoDecode);
572
+ this.audioSprite(file.key, file.urls ? file.urls : file.url, file.jsonURL, file.jsonData);
573
+ break;
574
+ case "audioSprite":
575
+ this.audioSprite(file.key, file.audioURL, file.jsonURL, file.jsonData);
576
576
  break;
577
577
  case "tilemap":
578
578
  // TODO
@@ -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.add.sound(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
+ }