Fix a regression on the displayed position of custom objects (#8604)

This commit is contained in:
D8H
2026-05-16 13:38:28 +02:00
committed by GitHub
parent c8d5f4600c
commit d9d8a7d3ea
3 changed files with 17 additions and 4 deletions
+2 -1
View File
@@ -25,7 +25,8 @@ namespace gdjs {
// Let the renderer do its final set up:
this._renderer.onCreated();
this._renderer.updatePosition();
// We don't call `this._renderer.updatePosition` because the camera has
// no effect unless it's moved.
}
override onGameResolutionResized(
+9
View File
@@ -281,9 +281,18 @@ namespace gdjs {
* @returns the scene the layer belongs to directly or indirectly
*/
getRuntimeScene(): gdjs.RuntimeScene {
// TODO Check that method is not wrongly called instead of `getInstanceContainer`.
return this._runtimeScene.getScene();
}
/**
* Returns the scene the layer directly belongs
* @returns the scene the layer directly belongs
*/
getInstanceContainer(): gdjs.RuntimeInstanceContainer {
return this._runtimeScene;
}
/**
* Called at each frame, after events are run and before rendering.
*/
@@ -829,7 +829,8 @@ namespace gdjs {
}
updatePosition(): void {
const runtimeGame = this._layer.getRuntimeScene().getGame();
const instanceContainer = this._layer.getInstanceContainer();
const runtimeGame = instanceContainer.getGame();
// Update the 3D camera position and rotation.
if (this._threeCamera) {
@@ -921,8 +922,10 @@ namespace gdjs {
const centerY =
this._layer.getCameraX() * effectivePixiZoom * angleSinValue +
this._layer.getCameraY() * effectivePixiZoom * angleCosValue;
this._pixiContainer.position.x = this._layer.getWidth() / 2 - centerX;
this._pixiContainer.position.y = this._layer.getHeight() / 2 - centerY;
this._pixiContainer.position.x =
instanceContainer.getViewportOriginX() - centerX;
this._pixiContainer.position.y =
instanceContainer.getViewportOriginY() - centerY;
}
// Pixel rounding for the Pixi rendering (be it for 2D only