@vpmedia/phaser 1.0.13 → 1.0.16

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.13",
3
+ "version": "1.0.16",
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",
@@ -80,25 +80,22 @@ export default class {
80
80
  }
81
81
 
82
82
  checkContextState() {
83
+ // this must be called from the final game state since input.onUp handlers are reset by state manager
83
84
  if (this.noAudio) {
84
- return false;
85
- }
86
- if (this.context.state === 'suspended') {
87
- this.game.input.onUp.addOnce(this.resumeAudioContext, this);
88
- return true;
85
+ return;
89
86
  }
90
- return false;
91
- }
92
-
93
- resumeAudioContext() {
94
- if (this.noAudio) {
87
+ if (this.game.device.iOS || this.game.device.android) {
88
+ // touch lock callback already handles context resume
95
89
  return;
96
90
  }
97
- const state = this.context.state;
98
- if (state === 'suspended') {
99
- this.context.resume().catch((e) => {
100
- this.game.exceptionHandler(e, { state });
101
- });
91
+ if (this.context.state === 'suspended') {
92
+ this.game.input.onUp.addOnce(() => {
93
+ if (this.context.state === 'suspended') {
94
+ this.context.resume().catch((e) => {
95
+ this.game.exceptionHandler(e, { state: this.context.state, reason: 'check' });
96
+ });
97
+ }
98
+ }, this);
102
99
  }
103
100
  }
104
101
 
@@ -117,7 +114,11 @@ export default class {
117
114
  } else {
118
115
  this._unlockSource.start(0);
119
116
  }
120
- this.resumeAudioContext();
117
+ if (this.context.state === 'suspended') {
118
+ this.context.resume().catch((e) => {
119
+ this.game.exceptionHandler(e, { state: this.context.state, reason: 'unlock' });
120
+ });
121
+ }
121
122
  return true;
122
123
  }
123
124
 
@@ -203,10 +204,14 @@ export default class {
203
204
  if (this.touchLocked && this._unlockSource !== null && (this._unlockSource.playbackState === this._unlockSource.PLAYING_STATE || this._unlockSource.playbackState === this._unlockSource.FINISHED_STATE)) {
204
205
  this.touchLocked = false;
205
206
  this._unlockSource = null;
206
- this.resumeAudioContext();
207
+ if (this.context.state === 'suspended') {
208
+ this.context.resume().catch((e) => {
209
+ this.game.exceptionHandler(e, { state: this.context.state, reason: 'update_suspended' });
210
+ });
211
+ }
207
212
  } else if (this.context.state === 'interrupted') {
208
213
  this.context.resume().catch((e) => {
209
- this.game.exceptionHandler(e, { state: this.context.state });
214
+ this.game.exceptionHandler(e, { state: this.context.state, reason: 'update_interrupted' });
210
215
  });
211
216
  }
212
217
  for (let i = 0; i < this._sounds.length; i += 1) {