@vpmedia/phaser 1.0.33 → 1.0.35
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 -2
- 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 +3 -3
- package/src/index.js +0 -2
- package/src/phaser/core/animation_parser.js +0 -16
- package/src/phaser/core/cache.js +3 -21
- package/src/phaser/core/const.js +0 -5
- package/src/phaser/core/device.js +0 -6
- package/src/phaser/core/device_util.js +0 -51
- package/src/phaser/core/game.js +3 -14
- package/src/phaser/core/loader.js +5 -65
- package/src/phaser/core/raf.js +0 -3
- package/src/phaser/core/time.js +0 -8
- package/src/phaser/display/canvas/renderer.js +0 -2
- package/src/phaser/display/webgl/render_texture.js +1 -1
- package/src/phaser/display/webgl/renderer.js +0 -2
- package/src/phaser/core/raf_fb.js +0 -75
- package/src/phaser/core/raf_to.js +0 -34
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vpmedia/phaser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.35",
|
|
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",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@babel/preset-env": "^7.20.2",
|
|
24
24
|
"@babel/register": "^7.18.9",
|
|
25
25
|
"babel-loader": "^8.3.0",
|
|
26
|
-
"eslint": "^8.
|
|
26
|
+
"eslint": "^8.29.0",
|
|
27
27
|
"eslint-config-prettier": "^8.5.0",
|
|
28
28
|
"eslint-plugin-import": "^2.26.0",
|
|
29
29
|
"eslint-plugin-jest": "^27.1.6",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"eslint-plugin-prettier": "^4.2.1",
|
|
32
32
|
"husky": "^8.0.2",
|
|
33
33
|
"jest": "^29.3.1",
|
|
34
|
-
"lint-staged": "^13.0
|
|
34
|
+
"lint-staged": "^13.1.0",
|
|
35
35
|
"prettier": "^2.8.0",
|
|
36
36
|
"webpack": "^5.75.0",
|
|
37
37
|
"webpack-cli": "^4.10.0"
|
package/src/index.js
CHANGED
|
@@ -20,7 +20,6 @@ import InputPointer from './phaser/core/input_pointer';
|
|
|
20
20
|
import InputTouch from './phaser/core/input_touch';
|
|
21
21
|
import Loader from './phaser/core/loader';
|
|
22
22
|
import GameLoopRAF from './phaser/core/raf';
|
|
23
|
-
import GameLoopTO from './phaser/core/raf_to';
|
|
24
23
|
import ScaleManager from './phaser/core/scale_manager';
|
|
25
24
|
import Scene from './phaser/core/scene';
|
|
26
25
|
import SceneManager from './phaser/core/scene_manager';
|
|
@@ -89,7 +88,6 @@ export {
|
|
|
89
88
|
InputTouch,
|
|
90
89
|
Loader,
|
|
91
90
|
GameLoopRAF,
|
|
92
|
-
GameLoopTO,
|
|
93
91
|
MathUtils,
|
|
94
92
|
StringUtils,
|
|
95
93
|
ScaleManager,
|
|
@@ -85,14 +85,6 @@ export function JSONData(game, json) {
|
|
|
85
85
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
/**
|
|
89
|
-
*
|
|
90
|
-
*/
|
|
91
|
-
export function JSONDataPyxel() {
|
|
92
|
-
// TODO
|
|
93
|
-
console.warn('animation_parser.JSONDataPyxel() is not implemented');
|
|
94
|
-
}
|
|
95
|
-
|
|
96
88
|
/**
|
|
97
89
|
*
|
|
98
90
|
* @param {object} game TBD
|
|
@@ -121,11 +113,3 @@ export function JSONDataHash(game, json) {
|
|
|
121
113
|
}
|
|
122
114
|
return data;
|
|
123
115
|
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
*
|
|
127
|
-
*/
|
|
128
|
-
export function XMLData() {
|
|
129
|
-
// TODO
|
|
130
|
-
console.warn('animation_parser.XMLData() is not implemented');
|
|
131
|
-
}
|
package/src/phaser/core/cache.js
CHANGED
|
@@ -8,8 +8,7 @@ import BaseTexture from '../display/webgl/base_texture';
|
|
|
8
8
|
import Signal from './signal';
|
|
9
9
|
import Frame from './frame';
|
|
10
10
|
import FrameData from './frame_data';
|
|
11
|
-
import {
|
|
12
|
-
import { TEXTURE_ATLAS_XML_STARLING, TEXTURE_ATLAS_JSON_PYXEL } from './const';
|
|
11
|
+
import { JSONData, JSONDataHash } from './animation_parser';
|
|
13
12
|
import { jsonBitmapFont, xmlBitmapFont } from './loader_parser';
|
|
14
13
|
|
|
15
14
|
export const CANVAS = 1;
|
|
@@ -24,7 +23,6 @@ export const BITMAPDATA = 9;
|
|
|
24
23
|
export const BITMAPFONT = 10;
|
|
25
24
|
export const JSON = 11;
|
|
26
25
|
export const XML = 12;
|
|
27
|
-
export const VIDEO = 13;
|
|
28
26
|
export const SHADER = 14;
|
|
29
27
|
export const RENDER_TEXTURE = 15;
|
|
30
28
|
|
|
@@ -38,7 +36,6 @@ export default class {
|
|
|
38
36
|
image: {},
|
|
39
37
|
texture: {},
|
|
40
38
|
sound: {},
|
|
41
|
-
video: {},
|
|
42
39
|
text: {},
|
|
43
40
|
json: {},
|
|
44
41
|
xml: {},
|
|
@@ -67,7 +64,6 @@ export default class {
|
|
|
67
64
|
this._cacheMap[BITMAPFONT] = this._cache.bitmapFont;
|
|
68
65
|
this._cacheMap[JSON] = this._cache.json;
|
|
69
66
|
this._cacheMap[XML] = this._cache.xml;
|
|
70
|
-
this._cacheMap[VIDEO] = this._cache.video;
|
|
71
67
|
this._cacheMap[SHADER] = this._cache.shader;
|
|
72
68
|
this._cacheMap[RENDER_TEXTURE] = this._cache.renderTexture;
|
|
73
69
|
this.addDefaultImage();
|
|
@@ -110,18 +106,14 @@ export default class {
|
|
|
110
106
|
return img;
|
|
111
107
|
}
|
|
112
108
|
|
|
113
|
-
addTextureAtlas(key, url, data, atlasData
|
|
109
|
+
addTextureAtlas(key, url, data, atlasData) {
|
|
114
110
|
const obj = {
|
|
115
111
|
key,
|
|
116
112
|
url,
|
|
117
113
|
data,
|
|
118
114
|
base: new BaseTexture(data),
|
|
119
115
|
};
|
|
120
|
-
if (
|
|
121
|
-
obj.frameData = XMLData(this.game, atlasData, key);
|
|
122
|
-
} else if (format === TEXTURE_ATLAS_JSON_PYXEL) {
|
|
123
|
-
obj.frameData = JSONDataPyxel(this.game, atlasData, key);
|
|
124
|
-
} else if (Array.isArray(atlasData.frames)) {
|
|
116
|
+
if (Array.isArray(atlasData.frames)) {
|
|
125
117
|
// Let's just work it out from the frames array
|
|
126
118
|
obj.frameData = JSONData(this.game, atlasData, key);
|
|
127
119
|
} else {
|
|
@@ -287,8 +279,6 @@ export default class {
|
|
|
287
279
|
return this.checkKey(XML, key);
|
|
288
280
|
}
|
|
289
281
|
|
|
290
|
-
// TODO video shader rendertexture physics
|
|
291
|
-
|
|
292
282
|
// GET
|
|
293
283
|
|
|
294
284
|
getItem(key, cache, method, property = null) {
|
|
@@ -357,10 +347,6 @@ export default class {
|
|
|
357
347
|
return this.getItem(key, XML, 'getXML', 'data');
|
|
358
348
|
}
|
|
359
349
|
|
|
360
|
-
getVideo(key) {
|
|
361
|
-
return this.getItem(key, VIDEO, 'getVideo');
|
|
362
|
-
}
|
|
363
|
-
|
|
364
350
|
getShader(key) {
|
|
365
351
|
return this.getItem(key, SHADER, 'getShader', 'data');
|
|
366
352
|
}
|
|
@@ -490,10 +476,6 @@ export default class {
|
|
|
490
476
|
delete this._cache.xml[key];
|
|
491
477
|
}
|
|
492
478
|
|
|
493
|
-
removeVideo(key) {
|
|
494
|
-
delete this._cache.video[key];
|
|
495
|
-
}
|
|
496
|
-
|
|
497
479
|
removeShader(key) {
|
|
498
480
|
delete this._cache.shader[key];
|
|
499
481
|
}
|
package/src/phaser/core/const.js
CHANGED
|
@@ -94,12 +94,7 @@ export const EMITTER = 11; // deprecated
|
|
|
94
94
|
export const RETROFONT = 18; // deprecated
|
|
95
95
|
export const ROPE = 20; // deprecated
|
|
96
96
|
export const CREATURE = 27; // deprecated
|
|
97
|
-
export const VIDEO = 28; // deprecated
|
|
98
97
|
export const PENDING_ATLAS = -1;
|
|
99
98
|
// sprite sheet atlas
|
|
100
99
|
export const TEXTURE_ATLAS_JSON_ARRAY = 0;
|
|
101
100
|
export const TEXTURE_ATLAS_JSON_HASH = 1;
|
|
102
|
-
export const TEXTURE_ATLAS_XML_STARLING = 2;
|
|
103
|
-
export const PHYSICS_LIME_CORONA_JSON = 3; // deprecated
|
|
104
|
-
export const PHYSICS_PHASER_JSON = 4; // deprecated
|
|
105
|
-
export const TEXTURE_ATLAS_JSON_PYXEL = 5;
|
|
@@ -31,12 +31,6 @@ export default class {
|
|
|
31
31
|
this.m4a = false;
|
|
32
32
|
this.webm = false;
|
|
33
33
|
this.dolby = false;
|
|
34
|
-
this.oggVideo = false;
|
|
35
|
-
this.h264Video = false;
|
|
36
|
-
this.mp4Video = false;
|
|
37
|
-
this.webmVideo = false;
|
|
38
|
-
this.vp9Video = false;
|
|
39
|
-
this.hlsVideo = false;
|
|
40
34
|
this.iPhone = false;
|
|
41
35
|
this.iPad = false;
|
|
42
36
|
this.pixelRatio = 1;
|
|
@@ -29,25 +29,6 @@ export function canPlayAudio(device, type) {
|
|
|
29
29
|
return false;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
* @param {object} device TBD
|
|
35
|
-
* @param {string} type TBD
|
|
36
|
-
* @returns {boolean} TBD
|
|
37
|
-
*/
|
|
38
|
-
export function canPlayVideo(device, type) {
|
|
39
|
-
if (type === 'webm' && (device.webmVideo || device.vp9Video)) {
|
|
40
|
-
return true;
|
|
41
|
-
} else if (type === 'mp4' && (device.mp4Video || device.h264Video)) {
|
|
42
|
-
return true;
|
|
43
|
-
} else if ((type === 'ogg' || type === 'ogv') && device.oggVideo) {
|
|
44
|
-
return true;
|
|
45
|
-
} else if (type === 'mpeg' && device.hlsVideo) {
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
32
|
/**
|
|
52
33
|
*
|
|
53
34
|
* @param {object} device TBD
|
|
@@ -170,37 +151,6 @@ export function checkBrowser(device) {
|
|
|
170
151
|
}
|
|
171
152
|
}
|
|
172
153
|
|
|
173
|
-
/**
|
|
174
|
-
*
|
|
175
|
-
* @param {object} device TBD
|
|
176
|
-
*/
|
|
177
|
-
export function checkVideo(device) {
|
|
178
|
-
const videoElement = document.createElement('video');
|
|
179
|
-
try {
|
|
180
|
-
if (videoElement.canPlayType) {
|
|
181
|
-
if (videoElement.canPlayType('video/ogg; codecs="theora"').replace(/^no$/, '')) {
|
|
182
|
-
device.oggVideo = true;
|
|
183
|
-
}
|
|
184
|
-
if (videoElement.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/, '')) {
|
|
185
|
-
// Without QuickTime, this value will be `undefined`. github.com/Modernizr/Modernizr/issues/546
|
|
186
|
-
device.h264Video = true;
|
|
187
|
-
device.mp4Video = true;
|
|
188
|
-
}
|
|
189
|
-
if (videoElement.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/, '')) {
|
|
190
|
-
device.webmVideo = true;
|
|
191
|
-
}
|
|
192
|
-
if (videoElement.canPlayType('video/webm; codecs="vp9"').replace(/^no$/, '')) {
|
|
193
|
-
device.vp9Video = true;
|
|
194
|
-
}
|
|
195
|
-
if (videoElement.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/, '')) {
|
|
196
|
-
device.hlsVideo = true;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
} catch (e) {
|
|
200
|
-
// pass
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
154
|
/**
|
|
205
155
|
*
|
|
206
156
|
* @param {object} device TBD
|
|
@@ -259,7 +209,6 @@ export function initialize(device) {
|
|
|
259
209
|
checkOS(device);
|
|
260
210
|
checkBrowser(device);
|
|
261
211
|
checkAudio(device);
|
|
262
|
-
checkVideo(device);
|
|
263
212
|
checkDevice(device);
|
|
264
213
|
checkFullScreenSupport(device);
|
|
265
214
|
checkInput(device);
|
package/src/phaser/core/game.js
CHANGED
|
@@ -12,7 +12,6 @@ import Input from './input';
|
|
|
12
12
|
import Device from './device';
|
|
13
13
|
import GameObjectFactory from './factory';
|
|
14
14
|
import RequestAnimationFrame from './raf';
|
|
15
|
-
import TimeOutAnimationFrame from './raf_to';
|
|
16
15
|
import ScaleManager from './scale_manager';
|
|
17
16
|
import SoundManager from './sound_manager';
|
|
18
17
|
import SceneManager from './scene_manager';
|
|
@@ -107,13 +106,9 @@ export default class {
|
|
|
107
106
|
this.sound.boot();
|
|
108
107
|
this.state.boot();
|
|
109
108
|
this.isRunning = true;
|
|
110
|
-
|
|
111
|
-
this.raf = new TimeOutAnimationFrame(this);
|
|
112
|
-
} else {
|
|
113
|
-
this.raf = new RequestAnimationFrame(this);
|
|
114
|
-
}
|
|
109
|
+
this.raf = new RequestAnimationFrame(this);
|
|
115
110
|
this.isKickStart = true;
|
|
116
|
-
if (window.focus
|
|
111
|
+
if (window.focus) {
|
|
117
112
|
window.focus();
|
|
118
113
|
}
|
|
119
114
|
this.raf.start();
|
|
@@ -189,9 +184,6 @@ export default class {
|
|
|
189
184
|
|
|
190
185
|
parseConfig(config) {
|
|
191
186
|
/* game */
|
|
192
|
-
this.parseConfigElement(config, 'isSkipWindowFocus', false);
|
|
193
|
-
this.parseConfigElement(config, 'forceSetTimeOut', false);
|
|
194
|
-
this.parseConfigElement(config, 'lockRender', false);
|
|
195
187
|
this.parseConfigElement(config, 'width', 800);
|
|
196
188
|
this.parseConfigElement(config, 'height', 600);
|
|
197
189
|
this.parseConfigElement(config, 'backgroundColor', 0x000000);
|
|
@@ -211,7 +203,7 @@ export default class {
|
|
|
211
203
|
this.parseConfigElement(config, 'preserveDrawingBuffer', false);
|
|
212
204
|
// Clear the Canvas each frame before rendering the display list.
|
|
213
205
|
// You can set this to `false` to gain some performance if your game always contains a background that completely fills the display.
|
|
214
|
-
this.parseConfigElement(config, 'clearBeforeRender',
|
|
206
|
+
this.parseConfigElement(config, 'clearBeforeRender', false);
|
|
215
207
|
// The Renderer this game will use. Either Const.RENDER_AUTO, Const.RENDER_CANVAS, Const.RENDER_WEBGL
|
|
216
208
|
this.parseConfigElement(config, 'renderType', RENDER_AUTO);
|
|
217
209
|
// Force audio disabled
|
|
@@ -340,9 +332,6 @@ export default class {
|
|
|
340
332
|
}
|
|
341
333
|
|
|
342
334
|
updateRender(elapsedTime) {
|
|
343
|
-
if (this.config.lockRender) {
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
335
|
this.state.preRender(elapsedTime);
|
|
347
336
|
this.renderer.render(this.stage);
|
|
348
337
|
this.state.render(elapsedTime);
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import Signal from './signal';
|
|
7
7
|
import Rectangle from '../geom/rectangle';
|
|
8
8
|
import { canPlayAudio } from './device_util';
|
|
9
|
-
import { TEXTURE_ATLAS_JSON_ARRAY, TEXTURE_ATLAS_JSON_HASH
|
|
9
|
+
import { TEXTURE_ATLAS_JSON_ARRAY, TEXTURE_ATLAS_JSON_HASH } from './const';
|
|
10
10
|
|
|
11
11
|
export const TILED_JSON = 6;
|
|
12
12
|
export const TILEMAP_CSV = 7;
|
|
@@ -278,12 +278,6 @@ export default class {
|
|
|
278
278
|
return this;
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
video() {
|
|
282
|
-
// TODO
|
|
283
|
-
console.warn('loader.video() is not implemented');
|
|
284
|
-
return this;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
281
|
tilemap() {
|
|
288
282
|
// TODO
|
|
289
283
|
console.warn('loader.tilemap() is not implemented');
|
|
@@ -335,36 +329,14 @@ export default class {
|
|
|
335
329
|
textureURL = key + '.png';
|
|
336
330
|
}
|
|
337
331
|
if (!atlasURL && !atlasData) {
|
|
338
|
-
|
|
339
|
-
atlasURL = key + '.xml';
|
|
340
|
-
} else {
|
|
341
|
-
atlasURL = key + '.json';
|
|
342
|
-
}
|
|
332
|
+
atlasURL = key + '.json';
|
|
343
333
|
}
|
|
344
334
|
// A URL to a json/xml file has been given
|
|
345
335
|
if (atlasURL) {
|
|
346
336
|
this.addToFileList('textureatlas', key, textureURL, { atlasURL, format });
|
|
347
337
|
} else {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
case TEXTURE_ATLAS_JSON_ARRAY:
|
|
351
|
-
if (typeof atlasData === 'string') {
|
|
352
|
-
atlasData = JSON.parse(atlasData);
|
|
353
|
-
}
|
|
354
|
-
break;
|
|
355
|
-
// An xml string or object has been given
|
|
356
|
-
case TEXTURE_ATLAS_XML_STARLING:
|
|
357
|
-
if (typeof atlasData === 'string') {
|
|
358
|
-
const xml = this.parseXml(atlasData);
|
|
359
|
-
if (!xml) {
|
|
360
|
-
throw new Error('Invalid Texture Atlas XML given');
|
|
361
|
-
}
|
|
362
|
-
atlasData = xml;
|
|
363
|
-
}
|
|
364
|
-
break;
|
|
365
|
-
default:
|
|
366
|
-
// pass
|
|
367
|
-
break;
|
|
338
|
+
if (format === TEXTURE_ATLAS_JSON_ARRAY && typeof atlasData === 'string') {
|
|
339
|
+
atlasData = JSON.parse(atlasData);
|
|
368
340
|
}
|
|
369
341
|
this.addToFileList('textureatlas', key, textureURL, { atlasURL: null, atlasData, format });
|
|
370
342
|
}
|
|
@@ -562,9 +534,6 @@ export default class {
|
|
|
562
534
|
case "spritesheet":
|
|
563
535
|
this.spritesheet(file.key, file.url, file.frameWidth, file.frameHeight, file.frameMax, file.margin, file.spacing);
|
|
564
536
|
break;
|
|
565
|
-
case "video":
|
|
566
|
-
this.video(file.key, file.urls ? file.urls : file.url);
|
|
567
|
-
break;
|
|
568
537
|
case "audio":
|
|
569
538
|
this.audio(file.key, file.urls ? file.urls : file.url);
|
|
570
539
|
break;
|
|
@@ -624,18 +593,6 @@ export default class {
|
|
|
624
593
|
this.fileError(file, null, 'No supported audio URL specified or device does not have audio playback support');
|
|
625
594
|
}
|
|
626
595
|
break;
|
|
627
|
-
case 'video':
|
|
628
|
-
file.url = this.getVideoURL(file.url);
|
|
629
|
-
if (file.url) {
|
|
630
|
-
if (file.asBlob) {
|
|
631
|
-
this.xhrLoad(file, this.transformUrl(file.url, file), 'blob', this.fileComplete);
|
|
632
|
-
} else {
|
|
633
|
-
this.loadVideoTag(file);
|
|
634
|
-
}
|
|
635
|
-
} else {
|
|
636
|
-
this.fileError(file, null, 'No supported video URL specified or device does not have video playback support');
|
|
637
|
-
}
|
|
638
|
-
break;
|
|
639
596
|
case 'json':
|
|
640
597
|
this.xhrLoad(file, this.transformUrl(file.url, file), 'text', this.jsonLoadComplete);
|
|
641
598
|
break;
|
|
@@ -690,11 +647,6 @@ export default class {
|
|
|
690
647
|
file.data.src = this.transformUrl(file.url, file);
|
|
691
648
|
}
|
|
692
649
|
|
|
693
|
-
loadVideoTag() {
|
|
694
|
-
// TODO
|
|
695
|
-
console.warn('loader.loadVideoTag() is not implemented');
|
|
696
|
-
}
|
|
697
|
-
|
|
698
650
|
xhrLoad(file, url, type, onload, onerror) {
|
|
699
651
|
const xhr = new XMLHttpRequest();
|
|
700
652
|
xhr.open('GET', url, true);
|
|
@@ -810,10 +762,8 @@ export default class {
|
|
|
810
762
|
} else {
|
|
811
763
|
// Load the JSON or XML before carrying on with the next file
|
|
812
764
|
loadNext = false;
|
|
813
|
-
if (file.format === TEXTURE_ATLAS_JSON_ARRAY || file.format === TEXTURE_ATLAS_JSON_HASH
|
|
765
|
+
if (file.format === TEXTURE_ATLAS_JSON_ARRAY || file.format === TEXTURE_ATLAS_JSON_HASH) {
|
|
814
766
|
this.xhrLoad(file, this.transformUrl(file.atlasURL, file), 'text', this.jsonLoadComplete);
|
|
815
|
-
} else if (file.format === TEXTURE_ATLAS_XML_STARLING) {
|
|
816
|
-
this.xhrLoad(file, this.transformUrl(file.atlasURL, file), 'text', this.xmlLoadComplete);
|
|
817
767
|
} else {
|
|
818
768
|
throw new Error('Invalid Texture Atlas format: ' + file.format);
|
|
819
769
|
}
|
|
@@ -843,16 +793,6 @@ export default class {
|
|
|
843
793
|
});
|
|
844
794
|
}
|
|
845
795
|
break;
|
|
846
|
-
case 'video':
|
|
847
|
-
if (file.asBlob) {
|
|
848
|
-
try {
|
|
849
|
-
file.data = xhr.response;
|
|
850
|
-
} catch (e) {
|
|
851
|
-
throw new Error('Unable to parse video file as Blob: ' + file.key);
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
this.cache.addVideo(file.key, file.url, file.data, file.asBlob);
|
|
855
|
-
break;
|
|
856
796
|
case 'audio':
|
|
857
797
|
file.data = xhr.response;
|
|
858
798
|
this.cache.addSound(file.key, file.url, file.data);
|
package/src/phaser/core/raf.js
CHANGED
|
@@ -20,7 +20,6 @@ export default class {
|
|
|
20
20
|
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'];
|
|
21
21
|
}
|
|
22
22
|
this.updateBinded = this.update.bind(this);
|
|
23
|
-
// this.updateBinded = time => this.update(time);
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
start() {
|
|
@@ -37,8 +36,6 @@ export default class {
|
|
|
37
36
|
if (!this.isRunning) {
|
|
38
37
|
return;
|
|
39
38
|
}
|
|
40
|
-
// floor the rafTime to make it equivalent to the Date.now() provided by updateSetTimeout (just below)
|
|
41
|
-
// this.game.update(Math.floor(rafTime));
|
|
42
39
|
this.game.update(rafTime);
|
|
43
40
|
this.timeoutId = window.requestAnimationFrame(this.updateBinded);
|
|
44
41
|
}
|
package/src/phaser/core/time.js
CHANGED
|
@@ -87,14 +87,6 @@ export default class {
|
|
|
87
87
|
this.now = time;
|
|
88
88
|
// elapsed time between previous call and now - this could be a high resolution value
|
|
89
89
|
this.elapsed = this.now - this.prevTime;
|
|
90
|
-
if (this.game.raf._isSetTimeOut) {
|
|
91
|
-
// console.log('Time isSet', this._desiredFps, 'te', this.timeExpected, 'time', time);
|
|
92
|
-
// time to call this function again in ms in case we're using timers instead of RequestAnimationFrame to update the game
|
|
93
|
-
this.timeToCall = Math.floor(Math.max(0, (1000.0 / this._desiredFps) - (this.timeExpected - time)));
|
|
94
|
-
// time when the next call is expected if using timers
|
|
95
|
-
this.timeExpected = time + this.timeToCall;
|
|
96
|
-
// console.log('Time expect', this.timeExpected);
|
|
97
|
-
}
|
|
98
90
|
if (this.advancedTiming) {
|
|
99
91
|
this.updateAdvancedTiming();
|
|
100
92
|
}
|
|
@@ -36,7 +36,6 @@ export default class {
|
|
|
36
36
|
};
|
|
37
37
|
this.mapBlendModes();
|
|
38
38
|
this.resize(this.width, this.height);
|
|
39
|
-
window.PhaserRegistry.DEFAULT_RENDERER = this;
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
render(root) {
|
|
@@ -67,7 +66,6 @@ export default class {
|
|
|
67
66
|
this.view = null;
|
|
68
67
|
this.context = null;
|
|
69
68
|
this.renderSession = null;
|
|
70
|
-
window.PhaserRegistry.DEFAULT_RENDERER = null;
|
|
71
69
|
}
|
|
72
70
|
|
|
73
71
|
resize(width, height) {
|
|
@@ -31,7 +31,7 @@ export default class extends Texture {
|
|
|
31
31
|
this.resolution = res;
|
|
32
32
|
this.frame = new Rectangle(0, 0, this.width * this.resolution, this.height * this.resolution);
|
|
33
33
|
this.crop = new Rectangle(0, 0, this.width * this.resolution, this.height * this.resolution);
|
|
34
|
-
this.renderer = renderer
|
|
34
|
+
this.renderer = renderer;
|
|
35
35
|
if (this.renderer.type === RENDER_WEBGL) {
|
|
36
36
|
const gl = this.renderer.gl;
|
|
37
37
|
this.baseTexture._dirty[gl.id] = false;
|
|
@@ -54,7 +54,6 @@ export default class {
|
|
|
54
54
|
this.renderSession.resolution = this.resolution;
|
|
55
55
|
this.initContext();
|
|
56
56
|
this.mapBlendModes();
|
|
57
|
-
window.PhaserRegistry.DEFAULT_RENDERER = this;
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
destroy() {
|
|
@@ -79,7 +78,6 @@ export default class {
|
|
|
79
78
|
this.renderSession = null;
|
|
80
79
|
remove(this);
|
|
81
80
|
window.PhaserRegistry.INSTANCES[this.glContextId] = null;
|
|
82
|
-
window.PhaserRegistry.DEFAULT_RENDERER = null;
|
|
83
81
|
window.PhaserRegistry.GL_CONTEXT_ID -= 1;
|
|
84
82
|
}
|
|
85
83
|
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
|
-
*/
|
|
6
|
-
export default class {
|
|
7
|
-
|
|
8
|
-
constructor(game, forceSetTimeOut = false) {
|
|
9
|
-
this.game = game;
|
|
10
|
-
this.forceSetTimeOut = forceSetTimeOut;
|
|
11
|
-
this.isRunning = false;
|
|
12
|
-
this._isSetTimeOut = false;
|
|
13
|
-
this._onLoop = null;
|
|
14
|
-
this._timeOutID = null;
|
|
15
|
-
const vendors = [
|
|
16
|
-
'ms',
|
|
17
|
-
'moz',
|
|
18
|
-
'webkit',
|
|
19
|
-
'o',
|
|
20
|
-
];
|
|
21
|
-
for (let x = 0; x < vendors.length && !window.requestAnimationFrame; x += 1) {
|
|
22
|
-
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
|
|
23
|
-
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
start() {
|
|
28
|
-
const scope = this;
|
|
29
|
-
this.isRunning = true;
|
|
30
|
-
if (!window.requestAnimationFrame || this.forceSetTimeOut) {
|
|
31
|
-
this._isSetTimeOut = true;
|
|
32
|
-
this._onLoop = () => scope.updateSetTimeout();
|
|
33
|
-
this._timeOutID = window.setTimeout(this._onLoop, 0);
|
|
34
|
-
} else {
|
|
35
|
-
this._isSetTimeOut = false;
|
|
36
|
-
this._onLoop = time => scope.updateRAF(time);
|
|
37
|
-
this._timeOutID = window.requestAnimationFrame(this._onLoop);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
stop() {
|
|
42
|
-
this.isRunning = false;
|
|
43
|
-
if (this._isSetTimeOut) {
|
|
44
|
-
window.clearTimeout(this._timeOutID);
|
|
45
|
-
} else {
|
|
46
|
-
window.cancelAnimationFrame(this._timeOutID);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
updateRAF(rafTime) {
|
|
51
|
-
if (!this.isRunning) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
// floor the rafTime to make it equivalent to the Date.now() provided by updateSetTimeout (just below)
|
|
55
|
-
this.game.update(Math.floor(rafTime));
|
|
56
|
-
this._timeOutID = window.requestAnimationFrame(this._onLoop);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
updateSetTimeout() {
|
|
60
|
-
if (!this.isRunning) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
this.game.update(Date.now());
|
|
64
|
-
this._timeOutID = window.setTimeout(this._onLoop, this.game.time.timeToCall);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
isSetTimeOut() {
|
|
68
|
-
return this._isSetTimeOut;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
isRAF() {
|
|
72
|
-
return this._isSetTimeOut === false;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
|
-
*/
|
|
6
|
-
export default class {
|
|
7
|
-
|
|
8
|
-
constructor(game) {
|
|
9
|
-
this.game = game;
|
|
10
|
-
this.isRunning = false;
|
|
11
|
-
this.isSetTimeOut = true;
|
|
12
|
-
this.timeoutId = null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
start() {
|
|
16
|
-
this.isRunning = true;
|
|
17
|
-
this.timeoutId = window.setTimeout(this.update, 0);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
stop() {
|
|
21
|
-
window.clearTimeout(this.timeoutId);
|
|
22
|
-
this.isRunning = false;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
update() {
|
|
26
|
-
if (!this.isRunning) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
this.game.update(Date.now());
|
|
30
|
-
this.timeoutId = window.setTimeout(this.update, this.game.time.timeToCall);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|