@vpmedia/phaser 1.0.40 → 1.0.41
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 +3 -22
- package/src/phaser/core/scene.js +0 -24
- package/src/phaser/core/scene_manager.js +4 -73
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vpmedia/phaser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.41",
|
|
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
|
@@ -245,31 +245,21 @@ export default class {
|
|
|
245
245
|
this.time.update(time);
|
|
246
246
|
if (this.isKickStart) {
|
|
247
247
|
this.updateLogic(this.time.desiredFpsMult);
|
|
248
|
-
|
|
249
|
-
this.updateRender(this.time.slowMotion * this.time.desiredFps);
|
|
248
|
+
this.renderer.render(this.stage);
|
|
250
249
|
this.isKickStart = false;
|
|
251
250
|
return;
|
|
252
251
|
}
|
|
253
252
|
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
253
|
if (this.time.time > this._nextFpsNotification) {
|
|
256
|
-
// only permit one fps notification per 10 seconds
|
|
257
254
|
this._nextFpsNotification = this.time.time + 10000;
|
|
258
|
-
// dispatch the notification signal
|
|
259
255
|
this.fpsProblemNotifier.dispatch();
|
|
260
256
|
}
|
|
261
|
-
// reset the _deltaTime accumulator which will cause all pending dropped frames to be permanently skipped
|
|
262
257
|
this._deltaTime = 0;
|
|
263
258
|
this._spiraling = 0;
|
|
264
|
-
|
|
265
|
-
this.updateRender(this.time.slowMotion * this.time.desiredFps);
|
|
259
|
+
this.renderer.render(this.stage);
|
|
266
260
|
} else {
|
|
267
|
-
// step size taking into account the slow motion speed
|
|
268
261
|
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
262
|
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
263
|
let count = 0;
|
|
274
264
|
this.updatesThisFrame = Math.floor(this._deltaTime / slowStep);
|
|
275
265
|
if (this.config.forceSingleUpdate) {
|
|
@@ -286,16 +276,13 @@ export default class {
|
|
|
286
276
|
this.time.refresh();
|
|
287
277
|
}
|
|
288
278
|
}
|
|
289
|
-
// detect spiraling (if the catch-up loop isn't fast enough, the number of iterations will increase constantly)
|
|
290
279
|
if (count > this._lastCount) {
|
|
291
280
|
this._spiraling += 1;
|
|
292
281
|
} else if (count < this._lastCount) {
|
|
293
|
-
// looks like it caught up successfully, reset the spiral alert counter
|
|
294
282
|
this._spiraling = 0;
|
|
295
283
|
}
|
|
296
284
|
this._lastCount = count;
|
|
297
|
-
|
|
298
|
-
this.updateRender(this._deltaTime / slowStep);
|
|
285
|
+
this.renderer.render(this.stage);
|
|
299
286
|
}
|
|
300
287
|
}
|
|
301
288
|
|
|
@@ -318,12 +305,6 @@ export default class {
|
|
|
318
305
|
this.stage.updateTransform();
|
|
319
306
|
}
|
|
320
307
|
|
|
321
|
-
updateRender(elapsedTime) {
|
|
322
|
-
this.state.preRender(elapsedTime);
|
|
323
|
-
this.renderer.render(this.stage);
|
|
324
|
-
this.state.render(elapsedTime);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
308
|
destroy() {
|
|
328
309
|
this.isPaused = true;
|
|
329
310
|
|
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 = {};
|