@vpmedia/phaser 1.8.0 → 1.9.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  @vpmedia/phaser
2
2
  ===============
3
3
 
4
- [![npm version](https://badge.fury.io/js/@vpmedia%2Fphaser.svg?v=1.8.0)](https://badge.fury.io/js/@vpmedia%2Fphaser)
4
+ [![npm version](https://badge.fury.io/js/@vpmedia%2Fphaser.svg?v=1.9.0)](https://badge.fury.io/js/@vpmedia%2Fphaser)
5
5
  [![Node.js CI](https://github.com/vpmedia/phaser/actions/workflows/node.js.yml/badge.svg)](https://github.com/vpmedia/phaser/actions/workflows/node.js.yml)
6
6
 
7
7
  @vpmedia/phaser is the modern ECMAScript port of the popular Phaser game engine v2.6.2.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vpmedia/phaser",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
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",
@@ -15,8 +15,8 @@ export default class {
15
15
  this.game = game;
16
16
  this.cache = game.cache;
17
17
  this.isLoading = false;
18
- this.isLogging = false;
19
- this.isUseRetry = false;
18
+ this.isUseLog = false;
19
+ this.isUseRetry = true;
20
20
  this.maxRetry = 1;
21
21
  this.hasLoaded = false;
22
22
  this.preloadSprite = null;
@@ -430,9 +430,9 @@ export default class {
430
430
  // Flight queue is empty but file list is not done being processed.
431
431
  // This indicates a critical internal error with no known recovery.
432
432
  console.warn('Loader - aborting: processing queue empty, loading may have stalled');
433
- const _this = this;
433
+ const scope = this;
434
434
  setTimeout(() => {
435
- _this.finishedLoading(true);
435
+ scope.finishedLoading(true);
436
436
  }, 2000);
437
437
  }
438
438
  }
@@ -557,7 +557,7 @@ export default class {
557
557
 
558
558
  loadImageTag(file) {
559
559
  this.log('loadImageTag', file);
560
- const _this = this;
560
+ const scope = this;
561
561
  file.data = new Image();
562
562
  file.data.name = file.key;
563
563
  if (this.crossOrigin) {
@@ -567,17 +567,17 @@ export default class {
567
567
  if (file.data.onload) {
568
568
  file.data.onload = null;
569
569
  file.data.onerror = null;
570
- _this.fileComplete(file);
570
+ scope.fileComplete(file);
571
571
  }
572
572
  };
573
573
  file.data.onerror = () => {
574
- if (_this.isUseRetry && (!file.numRetry || file.numRetry < _this.maxRetry)) {
574
+ if (scope.isUseRetry && (!file.numRetry || file.numRetry < scope.maxRetry)) {
575
575
  file.numRetry = !file.numRetry ? 1 : file.numRetry += 1;
576
- _this.loadImageTag(file);
576
+ scope.loadImageTag(file);
577
577
  } else if (file.data.onload) {
578
578
  file.data.onload = null;
579
579
  file.data.onerror = null;
580
- _this.fileError(file);
580
+ scope.fileError(file);
581
581
  }
582
582
  };
583
583
  file.data.src = this.transformUrl(file.url, file);
@@ -614,13 +614,18 @@ export default class {
614
614
  return null;
615
615
  };
616
616
  xhr.onerror = () => {
617
- try {
618
- return onerror.call(scope, file, xhr);
619
- } catch (e) {
620
- if (!scope.hasLoaded) {
621
- scope.asyncComplete(file, e.message || 'Exception');
622
- } else {
623
- scope.game.exceptionHandler(e);
617
+ if (scope.isUseRetry && (!file.numRetry || file.numRetry < scope.maxRetry)) {
618
+ file.numRetry = !file.numRetry ? 1 : file.numRetry += 1;
619
+ scope.xhrLoad(file, url, type, onload, onerror);
620
+ } else {
621
+ try {
622
+ return onerror.call(scope, file, xhr);
623
+ } catch (e) {
624
+ if (!scope.hasLoaded) {
625
+ scope.asyncComplete(file, e.message || 'Exception');
626
+ } else {
627
+ scope.game.exceptionHandler(e);
628
+ }
624
629
  }
625
630
  }
626
631
  return null;
@@ -824,7 +829,7 @@ export default class {
824
829
  }
825
830
 
826
831
  log(message, data = '') {
827
- if (!this.isLogging) {
832
+ if (!this.isUseLog) {
828
833
  return;
829
834
  }
830
835
  console.log(`[Loader] ${message}`, data);