zoltan88 Posted November 1, 2017 Share Posted November 1, 2017 So I'm currently using Phaser 2.9.1 and had a weird issue I've been struggling with today. If I use scaleMode RESIZE, then whenever the window resizes, the camera gets stuck at 0,0 and wont move anymore. Debugging reveals that the update function is called and the camera x,y are changed whenever the buttons to move the camera are pressed. However, it's like they are changed back right away again. One theory I had was that the world gets resized to the browser innerWidth and innerHeight upon resizing with that scaleMode. I found a thread after a while that fixed my problem. The problem now is that I want to know why it works.... So, doing the following in my create function: game.world.resize(5000, 5000); game.world.setBounds(0, 0, 5000, 5000); works, for some reason. Only doing resize does not work and I have to use setBounds there. But according to the docs, resize sets the size of the world and setBounds sets the camera to 0,0 and then sets the size of the world. Why would that make a difference when the browser is resized after the game has been created and the update function is running? If anyone could shed some light on this, I would greatly appreciate it :-). Also creds to Zekko and Carlos in the post above, for solving the issue 2 years ago Link to comment Share on other sites More sharing options...
samme Posted November 1, 2017 Share Posted November 1, 2017 I believe you need only world.setBounds. Use that instead of resize. Link to comment Share on other sites More sharing options...
zoltan88 Posted November 1, 2017 Author Share Posted November 1, 2017 4 minutes ago, samme said: I believe you need only world.setBounds. Use that instead of resize. That worked perfectly, thanks :). But why doesn't resize work then? Or is the documentation incomplete and the function does something not mentioned? Link to comment Share on other sites More sharing options...
samme Posted November 1, 2017 Share Posted November 1, 2017 I guess the docs are slightly incomplete. The difference is that world.setBounds actually sets a minimum size and world.resize never resizes below the minimum. word.resize is actually what gets called following a window resize; I don't think it's supposed to be a substitute for setBounds. zoltan88 1 Link to comment Share on other sites More sharing options...
zoltan88 Posted November 1, 2017 Author Share Posted November 1, 2017 2 hours ago, samme said: I guess the docs are slightly incomplete. The difference is that world.setBounds actually sets a minimum size and world.resize never resizes below the minimum. word.resize is actually what gets called following a window resize; I don't think it's supposed to be a substitute for setBounds. Alright, thank you! : ) Link to comment Share on other sites More sharing options...
Recommended Posts