@vpmedia/phaser 1.51.0 → 1.53.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 +3 -4
- package/src/phaser/display/canvas/renderer.js +1 -1
- package/src/phaser/display/canvas/tinter.js +25 -16
- package/types/phaser/display/canvas/tinter.d.ts +8 -3
- package/types/phaser/display/canvas/tinter.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.53.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;
|
|
@@ -265,9 +264,9 @@ export class Game {
|
|
|
265
264
|
*/
|
|
266
265
|
contextRestored(event) {
|
|
267
266
|
this.logger.info('contextRestored', event);
|
|
268
|
-
this.renderer.initContext();
|
|
269
|
-
// this.cache.clearGLTextures();
|
|
270
267
|
if (this.renderer) {
|
|
268
|
+
this.renderer.initContext();
|
|
269
|
+
// this.cache.clearGLTextures();
|
|
271
270
|
this.renderer.contextLost = false;
|
|
272
271
|
}
|
|
273
272
|
}
|
|
@@ -30,7 +30,7 @@ export class CanvasRenderer {
|
|
|
30
30
|
* @param {import('../../core/game.js').Game} game - TBD.
|
|
31
31
|
*/
|
|
32
32
|
constructor(game) {
|
|
33
|
-
detectCapabilities();
|
|
33
|
+
detectCapabilities(game);
|
|
34
34
|
this.type = RENDER_CANVAS;
|
|
35
35
|
this.resolution = game.config.resolution;
|
|
36
36
|
this.clearBeforeRender = game.config.clearBeforeRender;
|
|
@@ -71,18 +71,20 @@ export function tintWithPerPixel(texture, color, canvas) {
|
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* TBD.
|
|
74
|
+
* @param {import('../../core/game.js').Game} game - TBD.
|
|
74
75
|
* @returns {boolean} TBD.
|
|
76
|
+
* @throws {Error} TBD.
|
|
75
77
|
*/
|
|
76
|
-
export function checkInverseAlpha() {
|
|
78
|
+
export function checkInverseAlpha(game) {
|
|
77
79
|
// Check for DOM
|
|
78
80
|
if (document === undefined) {
|
|
79
|
-
|
|
81
|
+
throw new Error('Error getting Document for checkInverseAlpha()');
|
|
80
82
|
}
|
|
81
83
|
// Create canvas and context
|
|
82
84
|
const canvas = create('CanvasAlpha', 2, 1, true);
|
|
83
85
|
const context = canvas.getContext('2d');
|
|
84
86
|
if (!context) {
|
|
85
|
-
|
|
87
|
+
throw new Error('Error creating Canvas2D context for checkInverseAlpha()');
|
|
86
88
|
}
|
|
87
89
|
// Set canvas fill style
|
|
88
90
|
context.fillStyle = 'rgba(10, 20, 30, 0.5)';
|
|
@@ -112,12 +114,14 @@ export function checkInverseAlpha() {
|
|
|
112
114
|
|
|
113
115
|
/**
|
|
114
116
|
* TBD.
|
|
117
|
+
* @param {import('../../core/game.js').Game} game - TBD.
|
|
115
118
|
* @returns {boolean} TBD.
|
|
119
|
+
* @throws {Error} TBD.
|
|
116
120
|
*/
|
|
117
|
-
export function canUseNewCanvasBlendModes() {
|
|
121
|
+
export function canUseNewCanvasBlendModes(game) {
|
|
118
122
|
// Check for DOM
|
|
119
123
|
if (document === undefined) {
|
|
120
|
-
|
|
124
|
+
throw new Error('Error getting Document for canUseNewCanvasBlendModes()');
|
|
121
125
|
}
|
|
122
126
|
// Create test images
|
|
123
127
|
const pngHead = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/';
|
|
@@ -130,7 +134,7 @@ export function canUseNewCanvasBlendModes() {
|
|
|
130
134
|
const canvas = create('CanvasTinter', 6, 1, true);
|
|
131
135
|
const context = canvas.getContext('2d');
|
|
132
136
|
if (!context) {
|
|
133
|
-
|
|
137
|
+
throw new Error('Error creating Canvas2D context for canUseNewCanvasBlendModes()');
|
|
134
138
|
}
|
|
135
139
|
// Draw test images to canvas
|
|
136
140
|
context.globalCompositeOperation = 'multiply';
|
|
@@ -153,20 +157,25 @@ export function canUseNewCanvasBlendModes() {
|
|
|
153
157
|
|
|
154
158
|
/**
|
|
155
159
|
* TBD.
|
|
160
|
+
* @param {import('../../core/game.js').Game} game - TBD.
|
|
156
161
|
*/
|
|
157
|
-
export function detectCapabilities() {
|
|
162
|
+
export function detectCapabilities(game) {
|
|
158
163
|
if (!window.PhaserRegistry) {
|
|
159
164
|
window.PhaserRegistry = {};
|
|
160
165
|
}
|
|
161
|
-
|
|
162
|
-
window.PhaserRegistry.CAN_CANVAS_HANDLE_ALPHA = checkInverseAlpha();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
window.PhaserRegistry.
|
|
166
|
+
try {
|
|
167
|
+
window.PhaserRegistry.CAN_CANVAS_HANDLE_ALPHA = checkInverseAlpha(game);
|
|
168
|
+
} catch (error) {
|
|
169
|
+
game.exceptionHandler(error);
|
|
170
|
+
window.PhaserRegistry.CAN_CANVAS_HANDLE_ALPHA = false;
|
|
166
171
|
}
|
|
167
|
-
|
|
168
|
-
window.PhaserRegistry.
|
|
169
|
-
|
|
170
|
-
|
|
172
|
+
try {
|
|
173
|
+
window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY = canUseNewCanvasBlendModes(game);
|
|
174
|
+
} catch (error) {
|
|
175
|
+
game.exceptionHandler(error);
|
|
176
|
+
window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY = false;
|
|
171
177
|
}
|
|
178
|
+
window.PhaserRegistry.CANVAS_TINT_METHOD = window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY
|
|
179
|
+
? tintWithMultiply
|
|
180
|
+
: tintWithPerPixel;
|
|
172
181
|
}
|
|
@@ -21,16 +21,21 @@ export function tintWithMultiply(texture: object, color: object, canvas: HTMLCan
|
|
|
21
21
|
export function tintWithPerPixel(texture: object, color: object, canvas: HTMLCanvasElement): void;
|
|
22
22
|
/**
|
|
23
23
|
* TBD.
|
|
24
|
+
* @param {import('../../core/game.js').Game} game - TBD.
|
|
24
25
|
* @returns {boolean} TBD.
|
|
26
|
+
* @throws {Error} TBD.
|
|
25
27
|
*/
|
|
26
|
-
export function checkInverseAlpha(): boolean;
|
|
28
|
+
export function checkInverseAlpha(game: import("../../core/game.js").Game): boolean;
|
|
27
29
|
/**
|
|
28
30
|
* TBD.
|
|
31
|
+
* @param {import('../../core/game.js').Game} game - TBD.
|
|
29
32
|
* @returns {boolean} TBD.
|
|
33
|
+
* @throws {Error} TBD.
|
|
30
34
|
*/
|
|
31
|
-
export function canUseNewCanvasBlendModes(): boolean;
|
|
35
|
+
export function canUseNewCanvasBlendModes(game: import("../../core/game.js").Game): boolean;
|
|
32
36
|
/**
|
|
33
37
|
* TBD.
|
|
38
|
+
* @param {import('../../core/game.js').Game} game - TBD.
|
|
34
39
|
*/
|
|
35
|
-
export function detectCapabilities(): void;
|
|
40
|
+
export function detectCapabilities(game: import("../../core/game.js").Game): void;
|
|
36
41
|
//# sourceMappingURL=tinter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tinter.d.ts","sourceRoot":"","sources":["../../../../src/phaser/display/canvas/tinter.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,yCAJW,MAAM,SACN,MAAM,GACJ,MAAM,CAMlB;AAED;;;;;GAKG;AACH,0CAJW,MAAM,SACN,MAAM,UACN,iBAAiB,QAgB3B;AAED;;;;;GAKG;AACH,0CAJW,MAAM,SACN,MAAM,UACN,iBAAiB,QA4B3B;AAED
|
|
1
|
+
{"version":3,"file":"tinter.d.ts","sourceRoot":"","sources":["../../../../src/phaser/display/canvas/tinter.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,yCAJW,MAAM,SACN,MAAM,GACJ,MAAM,CAMlB;AAED;;;;;GAKG;AACH,0CAJW,MAAM,SACN,MAAM,UACN,iBAAiB,QAgB3B;AAED;;;;;GAKG;AACH,0CAJW,MAAM,SACN,MAAM,UACN,iBAAiB,QA4B3B;AAED;;;;;GAKG;AACH,wCAJW,OAAO,oBAAoB,EAAE,IAAI,GAC/B,OAAO,CAsCnB;AAED;;;;;GAKG;AACH,gDAJW,OAAO,oBAAoB,EAAE,IAAI,GAC/B,OAAO,CAsCnB;AAED;;;GAGG;AACH,yCAFW,OAAO,oBAAoB,EAAE,IAAI,QAqB3C"}
|