@vpmedia/phaser 1.0.40 → 1.1.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 +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/game.js +1 -73
- package/src/phaser/core/scene.js +0 -24
- package/src/phaser/core/scene_manager.js +4 -73
- package/src/phaser/core/time.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vpmedia/phaser",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.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",
|
package/src/phaser/core/game.js
CHANGED
|
@@ -55,14 +55,6 @@ export default class {
|
|
|
55
55
|
this.onResume = new Signal();
|
|
56
56
|
this.onBoot = new Signal();
|
|
57
57
|
this.isPaused = false;
|
|
58
|
-
this.currentUpdateID = 0;
|
|
59
|
-
this.updatesThisFrame = 1;
|
|
60
|
-
this._deltaTime = 0;
|
|
61
|
-
this._lastCount = 0;
|
|
62
|
-
this._spiraling = 0;
|
|
63
|
-
this.isKickStart = true;
|
|
64
|
-
this.fpsProblemNotifier = new Signal();
|
|
65
|
-
this._nextFpsNotification = 0;
|
|
66
58
|
this.parseConfig(gameConfig);
|
|
67
59
|
checkOS(this.device);
|
|
68
60
|
if (document.readyState === 'complete') {
|
|
@@ -99,7 +91,6 @@ export default class {
|
|
|
99
91
|
this.input.boot();
|
|
100
92
|
this.sound.boot();
|
|
101
93
|
this.state.boot();
|
|
102
|
-
this.isKickStart = true;
|
|
103
94
|
if (window.focus) {
|
|
104
95
|
window.focus();
|
|
105
96
|
}
|
|
@@ -243,66 +234,9 @@ export default class {
|
|
|
243
234
|
|
|
244
235
|
update(time) {
|
|
245
236
|
this.time.update(time);
|
|
246
|
-
if (this.isKickStart) {
|
|
247
|
-
this.updateLogic(this.time.desiredFpsMult);
|
|
248
|
-
// call the game render update exactly once every frame
|
|
249
|
-
this.updateRender(this.time.slowMotion * this.time.desiredFps);
|
|
250
|
-
this.isKickStart = false;
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
if (!this.config.forceSingleUpdate && this._spiraling > 1) {
|
|
254
|
-
// cause an event to warn the program that this CPU can't keep up with the current desiredFps rate
|
|
255
|
-
if (this.time.time > this._nextFpsNotification) {
|
|
256
|
-
// only permit one fps notification per 10 seconds
|
|
257
|
-
this._nextFpsNotification = this.time.time + 10000;
|
|
258
|
-
// dispatch the notification signal
|
|
259
|
-
this.fpsProblemNotifier.dispatch();
|
|
260
|
-
}
|
|
261
|
-
// reset the _deltaTime accumulator which will cause all pending dropped frames to be permanently skipped
|
|
262
|
-
this._deltaTime = 0;
|
|
263
|
-
this._spiraling = 0;
|
|
264
|
-
// call the game render update exactly once every frame
|
|
265
|
-
this.updateRender(this.time.slowMotion * this.time.desiredFps);
|
|
266
|
-
} else {
|
|
267
|
-
// step size taking into account the slow motion speed
|
|
268
|
-
const slowStep = this.time.slowMotion * 1000.0 / this.time.desiredFps;
|
|
269
|
-
// accumulate time until the slowStep threshold is met or exceeded... up to a limit of 3 catch-up frames at slowStep intervals
|
|
270
|
-
this._deltaTime += Math.max(Math.min(slowStep * 3, this.time.elapsed), 0);
|
|
271
|
-
// call the game update logic multiple times if necessary to "catch up" with dropped frames
|
|
272
|
-
// unless forceSingleUpdate is true
|
|
273
|
-
let count = 0;
|
|
274
|
-
this.updatesThisFrame = Math.floor(this._deltaTime / slowStep);
|
|
275
|
-
if (this.config.forceSingleUpdate) {
|
|
276
|
-
this.updatesThisFrame = Math.min(1, this.updatesThisFrame);
|
|
277
|
-
}
|
|
278
|
-
while (this._deltaTime >= slowStep) {
|
|
279
|
-
this._deltaTime -= slowStep;
|
|
280
|
-
this.currentUpdateID = count;
|
|
281
|
-
this.updateLogic(this.time.desiredFpsMult);
|
|
282
|
-
count += 1;
|
|
283
|
-
if (this.config.forceSingleUpdate && count === 1) {
|
|
284
|
-
break;
|
|
285
|
-
} else {
|
|
286
|
-
this.time.refresh();
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
// detect spiraling (if the catch-up loop isn't fast enough, the number of iterations will increase constantly)
|
|
290
|
-
if (count > this._lastCount) {
|
|
291
|
-
this._spiraling += 1;
|
|
292
|
-
} else if (count < this._lastCount) {
|
|
293
|
-
// looks like it caught up successfully, reset the spiral alert counter
|
|
294
|
-
this._spiraling = 0;
|
|
295
|
-
}
|
|
296
|
-
this._lastCount = count;
|
|
297
|
-
// call the game render update exactly once every frame unless we're playing catch-up from a spiral condition
|
|
298
|
-
this.updateRender(this._deltaTime / slowStep);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
updateLogic(timeStep) {
|
|
303
237
|
if (!this.isPaused) {
|
|
304
238
|
this.scale.preUpdate();
|
|
305
|
-
this.state.preUpdate(
|
|
239
|
+
this.state.preUpdate();
|
|
306
240
|
this.stage.preUpdate();
|
|
307
241
|
this.state.update();
|
|
308
242
|
this.stage.update();
|
|
@@ -311,17 +245,11 @@ export default class {
|
|
|
311
245
|
this.input.update();
|
|
312
246
|
this.stage.postUpdate();
|
|
313
247
|
} else {
|
|
314
|
-
// Scaling and device orientation changes are still reflected when paused.
|
|
315
248
|
this.scale.pauseUpdate();
|
|
316
249
|
this.state.pauseUpdate();
|
|
317
250
|
}
|
|
318
251
|
this.stage.updateTransform();
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
updateRender(elapsedTime) {
|
|
322
|
-
this.state.preRender(elapsedTime);
|
|
323
252
|
this.renderer.render(this.stage);
|
|
324
|
-
this.state.render(elapsedTime);
|
|
325
253
|
}
|
|
326
254
|
|
|
327
255
|
destroy() {
|
package/src/phaser/core/scene.js
CHANGED
|
@@ -18,14 +18,6 @@ export default class {
|
|
|
18
18
|
// inherit
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
loadUpdate() {
|
|
22
|
-
// inherit
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
loadRender() {
|
|
26
|
-
// inherit
|
|
27
|
-
}
|
|
28
|
-
|
|
29
21
|
create() {
|
|
30
22
|
// inherit
|
|
31
23
|
}
|
|
@@ -34,26 +26,10 @@ export default class {
|
|
|
34
26
|
// inherit
|
|
35
27
|
}
|
|
36
28
|
|
|
37
|
-
preRender() {
|
|
38
|
-
// inherit
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
render() {
|
|
42
|
-
// inherit
|
|
43
|
-
}
|
|
44
|
-
|
|
45
29
|
resize() {
|
|
46
30
|
// inherit
|
|
47
31
|
}
|
|
48
32
|
|
|
49
|
-
paused() {
|
|
50
|
-
// inherit
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
resumed() {
|
|
54
|
-
// inherit
|
|
55
|
-
}
|
|
56
|
-
|
|
57
33
|
pauseUpdate() {
|
|
58
34
|
// inherit
|
|
59
35
|
}
|
|
@@ -24,13 +24,7 @@ export default class {
|
|
|
24
24
|
this.onPreloadCallback = null;
|
|
25
25
|
this.onCreateCallback = null;
|
|
26
26
|
this.onUpdateCallback = null;
|
|
27
|
-
this.onRenderCallback = null;
|
|
28
27
|
this.onResizeCallback = null;
|
|
29
|
-
this.onPreRenderCallback = null;
|
|
30
|
-
this.onLoadUpdateCallback = null;
|
|
31
|
-
this.onLoadRenderCallback = null;
|
|
32
|
-
this.onPausedCallback = null;
|
|
33
|
-
this.onResumedCallback = null;
|
|
34
28
|
this.onPauseUpdateCallback = null;
|
|
35
29
|
this.onShutDownCallback = null;
|
|
36
30
|
}
|
|
@@ -68,15 +62,9 @@ export default class {
|
|
|
68
62
|
this.onInitCallback = null;
|
|
69
63
|
this.onShutDownCallback = null;
|
|
70
64
|
this.onPreloadCallback = null;
|
|
71
|
-
this.onLoadRenderCallback = null;
|
|
72
|
-
this.onLoadUpdateCallback = null;
|
|
73
65
|
this.onCreateCallback = null;
|
|
74
66
|
this.onUpdateCallback = null;
|
|
75
|
-
this.onPreRenderCallback = null;
|
|
76
|
-
this.onRenderCallback = null;
|
|
77
67
|
this.onResizeCallback = null;
|
|
78
|
-
this.onPausedCallback = null;
|
|
79
|
-
this.onResumedCallback = null;
|
|
80
68
|
this.onPauseUpdateCallback = null;
|
|
81
69
|
}
|
|
82
70
|
delete this.states[key];
|
|
@@ -179,15 +167,9 @@ export default class {
|
|
|
179
167
|
// Used when the state is set as being the current active state
|
|
180
168
|
this.onInitCallback = this.callbackContext.init || this.dummy;
|
|
181
169
|
this.onPreloadCallback = this.callbackContext.preload || null;
|
|
182
|
-
this.onLoadRenderCallback = this.callbackContext.loadRender || null;
|
|
183
|
-
this.onLoadUpdateCallback = this.callbackContext.loadUpdate || null;
|
|
184
170
|
this.onCreateCallback = this.callbackContext.create || null;
|
|
185
171
|
this.onUpdateCallback = this.callbackContext.update || null;
|
|
186
|
-
this.onPreRenderCallback = this.callbackContext.preRender || null;
|
|
187
|
-
this.onRenderCallback = this.callbackContext.render || null;
|
|
188
172
|
this.onResizeCallback = this.callbackContext.resize || null;
|
|
189
|
-
this.onPausedCallback = this.callbackContext.paused || null;
|
|
190
|
-
this.onResumedCallback = this.callbackContext.resumed || null;
|
|
191
173
|
this.onPauseUpdateCallback = this.callbackContext.pauseUpdate || null;
|
|
192
174
|
this.onShutDownCallback = this.callbackContext.shutdown || this.dummy;
|
|
193
175
|
this.current = key;
|
|
@@ -204,9 +186,6 @@ export default class {
|
|
|
204
186
|
}
|
|
205
187
|
|
|
206
188
|
loadComplete() {
|
|
207
|
-
if (this._created === false && this.onLoadUpdateCallback) {
|
|
208
|
-
this.onLoadUpdateCallback.call(this.callbackContext, this.game);
|
|
209
|
-
}
|
|
210
189
|
if (this._created === false && this.onCreateCallback) {
|
|
211
190
|
this._created = true;
|
|
212
191
|
this.onCreateCallback.call(this.callbackContext, this.game);
|
|
@@ -215,41 +194,15 @@ export default class {
|
|
|
215
194
|
}
|
|
216
195
|
}
|
|
217
196
|
|
|
218
|
-
pause() {
|
|
219
|
-
if (this._created && this.onPausedCallback) {
|
|
220
|
-
this.onPausedCallback.call(this.callbackContext, this.game);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
resume() {
|
|
225
|
-
if (this._created && this.onResumedCallback) {
|
|
226
|
-
this.onResumedCallback.call(this.callbackContext, this.game);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
197
|
update() {
|
|
231
|
-
if (this._created) {
|
|
232
|
-
|
|
233
|
-
this.onUpdateCallback.call(this.callbackContext, this.game);
|
|
234
|
-
}
|
|
235
|
-
} else if (this.onLoadUpdateCallback) {
|
|
236
|
-
this.onLoadUpdateCallback.call(this.callbackContext, this.game);
|
|
198
|
+
if (this._created && this.onUpdateCallback) {
|
|
199
|
+
this.onUpdateCallback.call(this.callbackContext, this.game);
|
|
237
200
|
}
|
|
238
201
|
}
|
|
239
202
|
|
|
240
203
|
pauseUpdate() {
|
|
241
|
-
if (this._created) {
|
|
242
|
-
|
|
243
|
-
this.onPauseUpdateCallback.call(this.callbackContext, this.game);
|
|
244
|
-
}
|
|
245
|
-
} else if (this.onLoadUpdateCallback) {
|
|
246
|
-
this.onLoadUpdateCallback.call(this.callbackContext, this.game);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
preRender(elapsedTime) {
|
|
251
|
-
if (this._created && this.onPreRenderCallback) {
|
|
252
|
-
this.onPreRenderCallback.call(this.callbackContext, this.game, elapsedTime);
|
|
204
|
+
if (this._created && this.onPauseUpdateCallback) {
|
|
205
|
+
this.onPauseUpdateCallback.call(this.callbackContext, this.game);
|
|
253
206
|
}
|
|
254
207
|
}
|
|
255
208
|
|
|
@@ -259,23 +212,6 @@ export default class {
|
|
|
259
212
|
}
|
|
260
213
|
}
|
|
261
214
|
|
|
262
|
-
render() {
|
|
263
|
-
if (this._created) {
|
|
264
|
-
if (this.onRenderCallback) {
|
|
265
|
-
if (this.game.renderer.type === RENDER_CANVAS) {
|
|
266
|
-
this.game.context.save();
|
|
267
|
-
this.game.context.setTransform(1, 0, 0, 1, 0, 0);
|
|
268
|
-
this.onRenderCallback.call(this.callbackContext, this.game);
|
|
269
|
-
this.game.context.restore();
|
|
270
|
-
} else {
|
|
271
|
-
this.onRenderCallback.call(this.callbackContext, this.game);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
} else if (this.onLoadRenderCallback) {
|
|
275
|
-
this.onLoadRenderCallback.call(this.callbackContext, this.game);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
215
|
destroy() {
|
|
280
216
|
this._clearWorld = true;
|
|
281
217
|
this._clearCache = true;
|
|
@@ -284,13 +220,8 @@ export default class {
|
|
|
284
220
|
this.onInitCallback = null;
|
|
285
221
|
this.onShutDownCallback = null;
|
|
286
222
|
this.onPreloadCallback = null;
|
|
287
|
-
this.onLoadRenderCallback = null;
|
|
288
|
-
this.onLoadUpdateCallback = null;
|
|
289
223
|
this.onCreateCallback = null;
|
|
290
224
|
this.onUpdateCallback = null;
|
|
291
|
-
this.onRenderCallback = null;
|
|
292
|
-
this.onPausedCallback = null;
|
|
293
|
-
this.onResumedCallback = null;
|
|
294
225
|
this.onPauseUpdateCallback = null;
|
|
295
226
|
this.game = null;
|
|
296
227
|
this.states = {};
|