@vpmedia/phaser 1.52.0 → 1.54.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/package.json +1 -1
- package/src/phaser/core/game.js +2 -10
- package/src/phaser/display/canvas/renderer.js +2 -1
- package/src/phaser/display/webgl/renderer.js +15 -7
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/display/canvas/renderer.d.ts +2 -1
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/types/phaser/display/webgl/renderer.d.ts +2 -1
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @vpmedia/phaser
|
|
2
2
|
|
|
3
|
-
[](https://badge.fury.io/js/@vpmedia%2Fphaser)
|
|
4
4
|
[](https://github.com/vpmedia/phaser/actions/workflows/ci.yml)
|
|
5
5
|
|
|
6
6
|
@vpmedia/phaser is the modern ECMAScript port of the popular Phaser game engine v2.6.2.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vpmedia/phaser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.54.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
|
@@ -136,11 +136,10 @@ export class Game {
|
|
|
136
136
|
* TBD.
|
|
137
137
|
*/
|
|
138
138
|
initRenderer() {
|
|
139
|
-
this.logger.info('initRenderer');
|
|
140
|
-
this.createRendererCanvas();
|
|
141
139
|
let isWebGlReady = false;
|
|
142
140
|
if (this.config.renderType === RENDER_AUTO || this.config.renderType === RENDER_WEBGL) {
|
|
143
141
|
try {
|
|
142
|
+
this.createRendererCanvas();
|
|
144
143
|
this.logger.info('initWebGLRenderer');
|
|
145
144
|
this.renderer = new WebGLRenderer(this);
|
|
146
145
|
this.context = null;
|
|
@@ -167,13 +166,6 @@ export class Game {
|
|
|
167
166
|
}
|
|
168
167
|
this.exceptionHandler(e, tags);
|
|
169
168
|
}
|
|
170
|
-
/*
|
|
171
|
-
this.renderer = new WebGLRenderer(this);
|
|
172
|
-
this.context = null;
|
|
173
|
-
this.canvas.addEventListener('webglcontextlost', this.contextLost.bind(this), false);
|
|
174
|
-
this.canvas.addEventListener('webglcontextrestored', this.contextRestored.bind(this), false);
|
|
175
|
-
isWebGlReady = true;
|
|
176
|
-
*/
|
|
177
169
|
}
|
|
178
170
|
if (!isWebGlReady) {
|
|
179
171
|
if (this.renderer) {
|
|
@@ -266,7 +258,7 @@ export class Game {
|
|
|
266
258
|
contextRestored(event) {
|
|
267
259
|
this.logger.info('contextRestored', event);
|
|
268
260
|
if (this.renderer) {
|
|
269
|
-
this.renderer.initContext();
|
|
261
|
+
this.renderer.initContext(this);
|
|
270
262
|
// this.cache.clearGLTextures();
|
|
271
263
|
this.renderer.contextLost = false;
|
|
272
264
|
}
|
|
@@ -70,7 +70,7 @@ export class WebGLRenderer {
|
|
|
70
70
|
this.renderSession.stencilManager = this.stencilManager;
|
|
71
71
|
this.renderSession.renderer = this;
|
|
72
72
|
this.renderSession.resolution = this.resolution;
|
|
73
|
-
this.initContext();
|
|
73
|
+
this.initContext(game);
|
|
74
74
|
this.mapBlendModes();
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -119,36 +119,44 @@ export class WebGLRenderer {
|
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
121
|
* TBD.
|
|
122
|
+
* @param {import('../../core/game.js').Game} game - TBD.
|
|
122
123
|
* @throws Error.
|
|
123
124
|
*/
|
|
124
|
-
initContext() {
|
|
125
|
+
initContext(game) {
|
|
126
|
+
game.logger.debug('initContext');
|
|
125
127
|
/** @type {WebGLRenderingContext & { id: number }} */
|
|
126
128
|
const gl =
|
|
127
129
|
this.view.getContext('webgl', this._contextOptions) ||
|
|
128
130
|
this.view.getContext('experimental-webgl', this._contextOptions);
|
|
129
131
|
this.gl = gl;
|
|
130
132
|
if (!gl) {
|
|
131
|
-
// fail, not able to get a context
|
|
132
133
|
throw new Error('Error creating WebGL context');
|
|
133
134
|
}
|
|
135
|
+
if (gl?.isContextLost()) {
|
|
136
|
+
game.logger.warn('WebGL context lost');
|
|
137
|
+
}
|
|
138
|
+
if (gl?.getError()) {
|
|
139
|
+
game.logger.warn('WebGL context error', { errorCode: gl?.getError() });
|
|
140
|
+
}
|
|
141
|
+
// set current context
|
|
134
142
|
this.initRegistry();
|
|
135
143
|
this.glContextId = window.PhaserRegistry.GL_CONTEXT_ID;
|
|
136
144
|
gl.id = window.PhaserRegistry.GL_CONTEXT_ID;
|
|
137
145
|
window.PhaserRegistry.GL_CONTEXTS[this.glContextId] = gl;
|
|
138
146
|
window.PhaserRegistry.INSTANCES[this.glContextId] = this;
|
|
139
147
|
window.PhaserRegistry.GL_CONTEXT_ID += 1;
|
|
140
|
-
// set
|
|
148
|
+
// set default settings
|
|
141
149
|
gl.disable(gl.DEPTH_TEST);
|
|
142
150
|
gl.disable(gl.CULL_FACE);
|
|
143
151
|
gl.enable(gl.BLEND);
|
|
144
|
-
//
|
|
152
|
+
// set context for managers
|
|
145
153
|
this.shaderManager.setContext(gl);
|
|
146
154
|
this.spriteBatch.setContext(gl);
|
|
147
155
|
this.stencilManager.setContext(gl);
|
|
148
156
|
this.filterManager.setContext(gl);
|
|
149
157
|
this.blendModeManager.setContext(gl);
|
|
150
|
-
this.renderSession.gl =
|
|
151
|
-
//
|
|
158
|
+
this.renderSession.gl = gl;
|
|
159
|
+
// set initial size
|
|
152
160
|
this.resize(this.width, this.height);
|
|
153
161
|
}
|
|
154
162
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"game.d.ts","sourceRoot":"","sources":["../../../src/phaser/core/game.js"],"names":[],"mappings":"AAqBA;IACE;;;OAGG;IACH,yBAFW,MAAM,EAoDhB;IA9CC,WAAgB;IAChB,WAAW;IACX,eAAgB;IAChB,cAAgB;IAChB,eAAiB;IACjB,yCAAoB;IACpB,oBAAiB;IACjB,kBAAqB;IACrB,gBAAmB;IACnB,2BAAe;IACf,uBAAe;IACf,aAAiB;IACjB,aAAiB;IACjB,aAAgB;IAChB,oBAAiB;IACjB,oBAAiB;IACjB,aAAiB;IACjB,WAAgB;IAChB,qBAAkB;IAClB,aAAiB;IACjB,eAA0B;IAC1B,qBAAqB;IACrB,QADW,MAAM,CACC;IAClB,gCAAgC;IAChC,QADW,iBAAiB,CACV;IAClB,+BAA+B;IAC/B,SADW,gBAAgB,CACR;IACnB,gBAA2B;IAC3B,iBAA4B;IAC5B,eAA0B;IAC1B,kBAAqB;IAkBvB;;OAEG;IACH,aA+BC;IAED;;OAEG;IACH,6BAeC;IAED;;OAEG;IACH,
|
|
1
|
+
{"version":3,"file":"game.d.ts","sourceRoot":"","sources":["../../../src/phaser/core/game.js"],"names":[],"mappings":"AAqBA;IACE;;;OAGG;IACH,yBAFW,MAAM,EAoDhB;IA9CC,WAAgB;IAChB,WAAW;IACX,eAAgB;IAChB,cAAgB;IAChB,eAAiB;IACjB,yCAAoB;IACpB,oBAAiB;IACjB,kBAAqB;IACrB,gBAAmB;IACnB,2BAAe;IACf,uBAAe;IACf,aAAiB;IACjB,aAAiB;IACjB,aAAgB;IAChB,oBAAiB;IACjB,oBAAiB;IACjB,aAAiB;IACjB,WAAgB;IAChB,qBAAkB;IAClB,aAAiB;IACjB,eAA0B;IAC1B,qBAAqB;IACrB,QADW,MAAM,CACC;IAClB,gCAAgC;IAChC,QADW,iBAAiB,CACV;IAClB,+BAA+B;IAC/B,SADW,gBAAgB,CACR;IACnB,gBAA2B;IAC3B,iBAA4B;IAC5B,eAA0B;IAC1B,kBAAqB;IAkBvB;;OAEG;IACH,aA+BC;IAED;;OAEG;IACH,6BAeC;IAED;;OAEG;IACH,qBAkDC;IA1CK,2BAkGK,iBAAiB,GAAG,KAAK,UAlGsB;IACpD,+BA6GK,iBAAiB,GAAG,KAAK,UA7G8B;IA2ClE;;;;;OAKG;IACH,2BAJW,MAAM,OACN,MAAM,gBACN,GAAC,QAQX;IAED;;;OAGG;IACH,oBAFW,MAAM,QAkChB;IAdG,sBAA+C;IAgBnD;;;OAGG;IACH,mBAFW,iBAAiB,GAAG,KAAK,QAQnC;IAED;;;OAGG;IACH,uBAFW,iBAAiB,GAAG,KAAK,QASnC;IAED;;;OAGG;IACH,aAFW,MAAM,QAoBhB;IAED;;OAEG;IACH,gBAwCC;CACF;+BA7U8B,+BAA+B;8BAEhC,8BAA8B;6BAU/B,oBAAoB;sCAFX,UAAU;kCAHd,cAAc;sBAJ1B,YAAY;sBAKZ,YAAY;uBACX,aAAa;6BAEP,oBAAoB;6BAGpB,oBAAoB;sBAC3B,YAAY;qBACb,WAAW;6BACH,oBAAoB;sBAC3B,YAAY;uBAbX,aAAa;uBANb,mBAAmB;uBAcnB,aAAa"}
|
|
@@ -53,8 +53,9 @@ export class CanvasRenderer {
|
|
|
53
53
|
mapBlendModes(): void;
|
|
54
54
|
/**
|
|
55
55
|
* TBD.
|
|
56
|
+
* @param {import('../../core/game.js').Game} game - TBD.
|
|
56
57
|
*/
|
|
57
|
-
initContext(): void;
|
|
58
|
+
initContext(game: import("../../core/game.js").Game): void;
|
|
58
59
|
}
|
|
59
60
|
import * as CanvasMaskManager from './masker.js';
|
|
60
61
|
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../../src/phaser/display/canvas/renderer.js"],"names":[],"mappings":"AA0BA;IACE;;;OAGG;IACH,kBAFW,OAAO,oBAAoB,EAAE,IAAI,EA6B3C;IAzBC,aAAyB;IACzB,gBAAwC;IACxC,uBAAsD;IACtD,iBAA0C;IAC1C,oBAAuB;IACvB,qBAAwB;IACxB,cAAyC;IACzC,eAA2C;IAC3C,wBAAuB;IACvB,uCAAuC;IACvC,SADW,wBAAwB,CACmC;IAItE,iBAAmB;IACnB,cAAc;IACd;;;;;;MAMC;IAKH;;;OAGG;IACH,aAFW,OAAO,qBAAqB,EAAE,KAAK,QAqB7C;IAED;;;OAGG;IACH,qBAFW,OAAO,QASjB;IAED;;;;OAIG;IACH,cAHW,MAAM,UACN,MAAM,QAchB;IAED;;;;;OAKG;IACH,mCAJW,OAAO,wBAAwB,EAAE,KAAK,WACtC,wBAAwB,UACxB,OAAO,sBAAsB,EAAE,MAAM,QAM/C;IAED;;OAEG;IACH,sBAwBC;IAED
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../../src/phaser/display/canvas/renderer.js"],"names":[],"mappings":"AA0BA;IACE;;;OAGG;IACH,kBAFW,OAAO,oBAAoB,EAAE,IAAI,EA6B3C;IAzBC,aAAyB;IACzB,gBAAwC;IACxC,uBAAsD;IACtD,iBAA0C;IAC1C,oBAAuB;IACvB,qBAAwB;IACxB,cAAyC;IACzC,eAA2C;IAC3C,wBAAuB;IACvB,uCAAuC;IACvC,SADW,wBAAwB,CACmC;IAItE,iBAAmB;IACnB,cAAc;IACd;;;;;;MAMC;IAKH;;;OAGG;IACH,aAFW,OAAO,qBAAqB,EAAE,KAAK,QAqB7C;IAED;;;OAGG;IACH,qBAFW,OAAO,QASjB;IAED;;;;OAIG;IACH,cAHW,MAAM,UACN,MAAM,QAchB;IAED;;;;;OAKG;IACH,mCAJW,OAAO,wBAAwB,EAAE,KAAK,WACtC,wBAAwB,UACxB,OAAO,sBAAsB,EAAE,MAAM,QAM/C;IAED;;OAEG;IACH,sBAwBC;IAED;;;OAGG;IACH,kBAFW,OAAO,oBAAoB,EAAE,IAAI,QAI3C;CACF;mCA/IkC,aAAa"}
|
|
@@ -42,9 +42,10 @@ export class WebGLRenderer {
|
|
|
42
42
|
initRegistry(): void;
|
|
43
43
|
/**
|
|
44
44
|
* TBD.
|
|
45
|
+
* @param {import('../../core/game.js').Game} game - TBD.
|
|
45
46
|
* @throws Error.
|
|
46
47
|
*/
|
|
47
|
-
initContext(): void;
|
|
48
|
+
initContext(game: import("../../core/game.js").Game): void;
|
|
48
49
|
glContextId: any;
|
|
49
50
|
/**
|
|
50
51
|
* TBD.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../../src/phaser/display/webgl/renderer.js"],"names":[],"mappings":"AA+BA;IACE;;;OAGG;IACH,kBAFW,OAAO,oBAAoB,EAAE,IAAI,EAwC3C;IArCC,aAAwB;IACxB,gBAAwC;IACxC,oBAAuB;IACvB,qBAAwB;IACxB,uBAAsD;IACtD,cAAuB;IACvB,eAAyB;IACzB,wBAAuB;IACvB;;;;;;;;MAQC;IACD,kBAA6B;IAC7B,cAAyB;IACzB,kCAA6C;IAC7C,8BAAyC;IACzC,kCAA6C;IAC7C,oCAA+C;IAC/C,wCAAmD;IACnD,kBAAuB;IAezB;;OAEG;IACH,gBAuBC;IALC;
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../../src/phaser/display/webgl/renderer.js"],"names":[],"mappings":"AA+BA;IACE;;;OAGG;IACH,kBAFW,OAAO,oBAAoB,EAAE,IAAI,EAwC3C;IArCC,aAAwB;IACxB,gBAAwC;IACxC,oBAAuB;IACvB,qBAAwB;IACxB,uBAAsD;IACtD,cAAuB;IACvB,eAAyB;IACzB,wBAAuB;IACvB;;;;;;;;MAQC;IACD,kBAA6B;IAC7B,cAAyB;IACzB,kCAA6C;IAC7C,8BAAyC;IACzC,kCAA6C;IAC7C,oCAA+C;IAC/C,wCAAmD;IACnD,kBAAuB;IAezB;;OAEG;IACH,gBAuBC;IALC;YA6ByC,MAAM;MA7BjC;IAOhB;;OAEG;IACH,qBAUC;IAED;;;;OAIG;IACH,kBAHW,OAAO,oBAAoB,EAAE,IAAI,QAuC3C;IAlBC,iBAAsD;IAoBxD;;;OAGG;IACH,cAFW,OAAO,qBAAqB,EAAE,KAAK,QAkB7C;IAED;;;;;;OAMG;IACH,mCALW,OAAO,iCAAiC,EAAE,aAAa,cACvD,KAAK,UACL,MAAM,UACN,OAAO,sBAAsB,EAAE,MAAM,QAoB/C;IAED;;;;OAIG;IACH,cAHW,MAAM,UACN,MAAM,QAchB;IAED;;;;OAIG;IACH,uBAHW,OAAO,mBAAmB,EAAE,WAAW,GACrC,OAAO,CAsCnB;IAED;;OAEG;IACH,sBAwBC;CACF;sBAxRqB,qBAAqB;mCAMR,qBAAqB;iCACvB,mBAAmB;mCAHjB,qBAAqB;oCAIpB,sBAAsB;sCALpB,oBAAoB"}
|