Jump to content

[BUG] Setting setGameSize changs world bounds.


Recommended Posts


I'm testing some things with Phaser and I like it a lot. I have my own scaling model, where I do my calculations and after that I run this:

var realwidth = 600; // Real game width, without scaling. I use this var to do my position calculations
PTM = scaledwidth/realwidth;
game.scale.setGameSize(scaledwidth, scaledheight);

This way, all my game is scaled perfectly. One problem is that elsewhere in my code I have this:

game.world.setBounds(0, -1000000000000, realwidth, 2000000000000); // Infinite heigth. Whatever xD

The problem is that when I do game.scale.setGameSize(scaledwidth, scaledheight); with a size higher that realwidth, the world bounds are increased altough they are actually scaled with game.world.scale.set(PTM); (saw looking at game.world.bounds) so, if I have world bounds with size 600, if the scaled width is 700, the world bounds are set to 700, but because all the world is also scaled with game.world.scale.set(PTM); (including bounds) then in reality I came up with bounds bigger than my realwidth.

I can workaround this by calling game.world.setBounds each time after calling game.scale.setGameSize, but I don't think that this is the way to go. Maybe the engine should check if the world is scaled before touching the bounds and increase or decrease the bounds depending on the scaling factor. Or maybe check if the bounds are set manually and do not modify them if the user has touched them. Or maybe simply add a note on the wiki under setGameSize telling that the world bounds are touched. Got pissed off for 2 days looking why this was happening.


PD: Don't know why, can't set first code block to JavaScript xD

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...