File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,7 +25,8 @@ namespace gdjs {
2525
2626 // Let the renderer do its final set up:
2727 this . _renderer . onCreated ( ) ;
28- this . _renderer . updatePosition ( ) ;
28+ // We don't call `this._renderer.updatePosition` because the camera has
29+ // no effect unless it's moved.
2930 }
3031
3132 override onGameResolutionResized (
Original file line number Diff line number Diff line change @@ -281,9 +281,18 @@ namespace gdjs {
281281 * @returns the scene the layer belongs to directly or indirectly
282282 */
283283 getRuntimeScene ( ) : gdjs . RuntimeScene {
284+ // TODO Check that method is not wrongly called instead of `getInstanceContainer`.
284285 return this . _runtimeScene . getScene ( ) ;
285286 }
286287
288+ /**
289+ * Returns the scene the layer directly belongs
290+ * @returns the scene the layer directly belongs
291+ */
292+ getInstanceContainer ( ) : gdjs . RuntimeInstanceContainer {
293+ return this . _runtimeScene ;
294+ }
295+
287296 /**
288297 * Called at each frame, after events are run and before rendering.
289298 */
Original file line number Diff line number Diff line change @@ -829,7 +829,8 @@ namespace gdjs {
829829 }
830830
831831 updatePosition ( ) : void {
832- const runtimeGame = this . _layer . getRuntimeScene ( ) . getGame ( ) ;
832+ const instanceContainer = this . _layer . getInstanceContainer ( ) ;
833+ const runtimeGame = instanceContainer . getGame ( ) ;
833834
834835 // Update the 3D camera position and rotation.
835836 if ( this . _threeCamera ) {
@@ -921,8 +922,10 @@ namespace gdjs {
921922 const centerY =
922923 this . _layer . getCameraX ( ) * effectivePixiZoom * angleSinValue +
923924 this . _layer . getCameraY ( ) * effectivePixiZoom * angleCosValue ;
924- this . _pixiContainer . position . x = this . _layer . getWidth ( ) / 2 - centerX ;
925- this . _pixiContainer . position . y = this . _layer . getHeight ( ) / 2 - centerY ;
925+ this . _pixiContainer . position . x =
926+ instanceContainer . getViewportOriginX ( ) - centerX ;
927+ this . _pixiContainer . position . y =
928+ instanceContainer . getViewportOriginY ( ) - centerY ;
926929 }
927930
928931 // Pixel rounding for the Pixi rendering (be it for 2D only
You can’t perform that action at this time.
0 commit comments