@vpmedia/phaser 1.0.22 → 1.0.24

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.22",
3
+ "version": "1.0.24",
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",
@@ -72,6 +72,7 @@ export default class {
72
72
  this.masterGain.gain.value = 1;
73
73
  this.masterGain.connect(this.context.destination);
74
74
  // handle audio state unlock
75
+ // possible states: interrupted, suspended, running, closed
75
76
  this.onUnlockEventBinded = this.onUnlockEvent.bind(this);
76
77
  if (this.context.state === 'suspended' || this.context.state === 'interrupted') {
77
78
  this.addUnlockHandlers();
@@ -80,7 +81,7 @@ export default class {
80
81
  this.onLockChange.dispatch('onContextStateChange', { state: this.context.state, isLocked: this.isLocked });
81
82
  if (!this.isLocked && (this.context.state === 'suspended' || this.context.state === 'interrupted')) {
82
83
  this.addUnlockHandlers();
83
- } else if (this.isLocked) {
84
+ } else if (this.isLocked && this.context.state === 'running') {
84
85
  this.removeUnlockHandlers();
85
86
  }
86
87
  });
@@ -106,17 +107,17 @@ export default class {
106
107
 
107
108
  onUnlockEvent(event) {
108
109
  const initialState = this.context.state;
109
- if (this.context.state !== 'suspended' && this.context.state !== 'interrupted') {
110
- this.onLockChange.dispatch('onUnlockResumeDenied', { state: this.context.state, isLocked: this.isLocked, event });
110
+ if (initialState !== 'suspended' && initialState !== 'interrupted') {
111
+ this.onLockChange.dispatch('onUnlockResumeDenied', { state: initialState, isLocked: this.isLocked, event });
111
112
  this.removeUnlockHandlers();
112
113
  return;
113
114
  }
114
- this.onLockChange.dispatch('onContextResumeStart', { state: this.context.state, isLocked: this.isLocked, event });
115
+ this.onLockChange.dispatch('onContextResumeStart', { state: initialState, isLocked: this.isLocked, event });
115
116
  this.context.resume().then(() => {
116
- this.onLockChange.dispatch('onContextResumeResult', { state: this.context.state, isLocked: this.isLocked });
117
+ this.onLockChange.dispatch('onContextResumeResult', { initialState, state: this.context.state, isLocked: this.isLocked });
117
118
  this.removeUnlockHandlers();
118
119
  }).catch((e) => {
119
- this.onLockChange.dispatch('onContextResumeReject', { state: this.context.state, isLocked: this.isLocked, error: e });
120
+ this.onLockChange.dispatch('onContextResumeReject', { initialState, state: this.context.state, isLocked: this.isLocked, error: e });
120
121
  this.removeUnlockHandlers();
121
122
  this.game.exceptionHandler(e, { initialState, state: this.context.state });
122
123
  });