@vpmedia/phaser 1.0.18 → 1.0.19
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/phaser/core/input.js +0 -27
- package/src/phaser/core/input_mspointer.js +0 -2
- package/src/phaser/core/input_touch.js +0 -2
- package/src/phaser/core/sound_manager.js +19 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vpmedia/phaser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
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/phaser/core/input.js
CHANGED
|
@@ -137,33 +137,6 @@ export default class {
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
addTouchLockCallback(callback, context, onEnd = false) {
|
|
141
|
-
this.lockCallbacks.push({ callback, context, onEnd });
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
removeTouchLockCallback(callback, context) {
|
|
145
|
-
let i = this.lockCallbacks.length;
|
|
146
|
-
while (i) {
|
|
147
|
-
i -= 1;
|
|
148
|
-
if (this.lockCallbacks[i].callback === callback && this.lockCallbacks[i].context === context) {
|
|
149
|
-
this.lockCallbacks.splice(i, 1);
|
|
150
|
-
return true;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
executeTouchLockCallbacks(onEnd, event) {
|
|
157
|
-
let i = this.lockCallbacks.length;
|
|
158
|
-
while (i) {
|
|
159
|
-
i -= 1;
|
|
160
|
-
const cb = this.lockCallbacks[i];
|
|
161
|
-
if (cb.onEnd === onEnd && cb.callback.call(cb.context, this, event)) {
|
|
162
|
-
this.lockCallbacks.splice(i, 1);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
140
|
addPointer() {
|
|
168
141
|
if (this.pointers.length >= MAX_POINTERS) {
|
|
169
142
|
console.warn('Input.addPointer: Maximum limit of ' + MAX_POINTERS + ' pointers reached.');
|
|
@@ -77,7 +77,6 @@ export default class {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
onPointerDown(event) {
|
|
80
|
-
this.game.input.executeTouchLockCallbacks(false, event);
|
|
81
80
|
this.event = event;
|
|
82
81
|
this.eventPreventDefault(event);
|
|
83
82
|
if (this.pointerDownCallback) {
|
|
@@ -112,7 +111,6 @@ export default class {
|
|
|
112
111
|
}
|
|
113
112
|
|
|
114
113
|
onPointerUp(event) {
|
|
115
|
-
this.game.input.executeTouchLockCallbacks(true, event);
|
|
116
114
|
this.event = event;
|
|
117
115
|
this.eventPreventDefault(event);
|
|
118
116
|
if (this.pointerUpCallback) {
|
|
@@ -66,7 +66,6 @@ export default class {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
onTouchStart(event) {
|
|
69
|
-
this.game.input.executeTouchLockCallbacks(false, event);
|
|
70
69
|
this.event = event;
|
|
71
70
|
if (!this.game.input.enabled || !this.enabled) {
|
|
72
71
|
return;
|
|
@@ -130,7 +129,6 @@ export default class {
|
|
|
130
129
|
}
|
|
131
130
|
|
|
132
131
|
onTouchEnd(event) {
|
|
133
|
-
this.game.input.executeTouchLockCallbacks(true, event);
|
|
134
132
|
this.event = event;
|
|
135
133
|
if (this.touchEndCallback) {
|
|
136
134
|
this.touchEndCallback.call(this.callbackContext, event);
|
|
@@ -70,16 +70,20 @@ export default class {
|
|
|
70
70
|
}
|
|
71
71
|
this.masterGain.gain.value = 1;
|
|
72
72
|
this.masterGain.connect(this.context.destination);
|
|
73
|
-
// handle audio
|
|
74
|
-
|
|
75
|
-
this.
|
|
76
|
-
console.log("AudioContext change state", this.context.state);
|
|
77
|
-
};
|
|
78
|
-
if (this.context.state === 'suspended') {
|
|
79
|
-
this.isLocked = true;
|
|
80
|
-
this.onUnlockEventBinded = this.onUnlockEvent.bind(this);
|
|
73
|
+
// handle audio state unlock
|
|
74
|
+
this.onUnlockEventBinded = this.onUnlockEvent.bind(this);
|
|
75
|
+
if (this.isUnlockNeeded()) {
|
|
81
76
|
this.addUnlockHandlers();
|
|
82
77
|
}
|
|
78
|
+
this.context.addEventListener('statechange', () => {
|
|
79
|
+
if (this.isUnlockNeeded()) {
|
|
80
|
+
this.addUnlockHandlers();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
isUnlockNeeded() {
|
|
86
|
+
return !this.isLocked && !this.noAudio && (this.context.state === 'suspended' || this.context.state === 'interrupted');
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
addUnlockHandlers() {
|
|
@@ -87,6 +91,7 @@ export default class {
|
|
|
87
91
|
document.body.addEventListener('touchend', this.onUnlockEventBinded, false);
|
|
88
92
|
document.body.addEventListener('click', this.onUnlockEventBinded, false);
|
|
89
93
|
document.body.addEventListener('keydown', this.onUnlockEventBinded, false);
|
|
94
|
+
this.isLocked = true;
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
removeUnlockHandlers() {
|
|
@@ -94,24 +99,23 @@ export default class {
|
|
|
94
99
|
document.body.removeEventListener('touchend', this.onUnlockEventBinded);
|
|
95
100
|
document.body.removeEventListener('click', this.onUnlockEventBinded);
|
|
96
101
|
document.body.removeEventListener('keydown', this.onUnlockEventBinded);
|
|
102
|
+
this.isLocked = false;
|
|
97
103
|
}
|
|
98
104
|
|
|
99
|
-
onUnlockEvent(
|
|
100
|
-
if (this.
|
|
105
|
+
onUnlockEvent() {
|
|
106
|
+
if (!this.isUnlockNeeded()) {
|
|
107
|
+
this.removeUnlockHandlers();
|
|
101
108
|
return;
|
|
102
109
|
}
|
|
103
|
-
|
|
110
|
+
const initialState = this.context.state;
|
|
104
111
|
this.context.resume().then(() => {
|
|
105
112
|
this.removeUnlockHandlers();
|
|
106
113
|
}).catch((e) => {
|
|
107
114
|
this.removeUnlockHandlers();
|
|
108
|
-
this.game.exceptionHandler(e, { state: this.context.state });
|
|
115
|
+
this.game.exceptionHandler(e, { initialState, state: this.context.state });
|
|
109
116
|
});
|
|
110
117
|
}
|
|
111
118
|
|
|
112
|
-
checkContextState() {
|
|
113
|
-
}
|
|
114
|
-
|
|
115
119
|
stopAll() {
|
|
116
120
|
if (this.noAudio) {
|
|
117
121
|
return;
|