@unboxy/phaser-sdk 0.2.27 → 0.2.28
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/dist/editor/EditorBridge.js +18 -19
- package/package.json +1 -1
|
@@ -259,27 +259,26 @@ function computeScreenRect(game, go) {
|
|
|
259
259
|
const canvasY = (worldRect.y - cam.scrollY) * cam.zoom;
|
|
260
260
|
const canvasW = worldRect.width * cam.zoom;
|
|
261
261
|
const canvasH = worldRect.height * cam.zoom;
|
|
262
|
-
//
|
|
263
|
-
//
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
//
|
|
262
|
+
// Convert logical canvas pixels → CSS pixels using the canvas's actual
|
|
263
|
+
// displayed size (avoids depending on which direction Phaser's displayScale
|
|
264
|
+
// goes — we just measure it). Canvas may be letterboxed/pillarboxed inside
|
|
265
|
+
// the iframe under Scale.FIT; getBoundingClientRect gives both the size
|
|
266
|
+
// and the offset.
|
|
267
267
|
const canvas = game.canvas;
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
if (
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
268
|
+
if (!canvas || typeof canvas.getBoundingClientRect !== 'function')
|
|
269
|
+
return null;
|
|
270
|
+
const cssRect = canvas.getBoundingClientRect();
|
|
271
|
+
const logicalW = game.scale.width;
|
|
272
|
+
const logicalH = game.scale.height;
|
|
273
|
+
if (!logicalW || !logicalH)
|
|
274
|
+
return null;
|
|
275
|
+
const sx = cssRect.width / logicalW;
|
|
276
|
+
const sy = cssRect.height / logicalH;
|
|
278
277
|
return {
|
|
279
|
-
x:
|
|
280
|
-
y:
|
|
281
|
-
width: canvasW *
|
|
282
|
-
height: canvasH *
|
|
278
|
+
x: cssRect.left + canvasX * sx,
|
|
279
|
+
y: cssRect.top + canvasY * sy,
|
|
280
|
+
width: canvasW * sx,
|
|
281
|
+
height: canvasH * sy,
|
|
283
282
|
};
|
|
284
283
|
}
|
|
285
284
|
function readActiveManifest(game) {
|