In the following code, s2d.setFixedSize() has no effect. The scene's size does not get changed, and resizing the screen still changes it.

class Main extends hxd.App {
    var bgTile : h2d.Tile;

    override function init() {
        s2d.setFixedSize(500, 500);

        bgTile = h2d.Tile.fromColor(0xFFFFFF, s2d.width, s2d.height);
        new h2d.Bitmap(bgTile, s2d);
    }

    override function update(dt:Float) {
    }

    static function main() {
        new Main();
    }
}

1 Answers

3
Yanrishatum On Best Solutions

Most likely you misunderstood what this function does. (But that's understandable due to documentation being written in ambiguous way)
When you call setFixedSize you do 2 things:

  1. You set s2d.width and s2d.height to be a static value you set in function call.
  2. Due to how RenderContext operates, if s2d size does not match the window size, it gets stretched to fill entire screen.

Most likely you expected it to not scale and remain of static size even when window gets resized. It's not possible currently. Documentation of setFixedSize states that it prevents automatic scene resizing, and it indeed does that, by stretching scene instead of resizing it to match the window size. (And yes, while it does what it says, it's easy to misunderstand)

There is a PR pending that reworks scaling of s2d, which would deprecate setFixedSize and will provide better solution for scaling in general.