bartk Posted September 25, 2015 Share Posted September 25, 2015 Heya, I'm building a game in which I can enter a building, which I'm handling via states. In other words, when my character overlaps with the door, the program starts a new state in which the interior of the building is built. Now, I want the interior to have smaller dimensions than the world, so I want to change the game size when I start this new state.I tried this:create: function(){ //game size was 1000x700, I want to scale it to 700x450 game.width = 700; game.height = 450; //rest of creation code...}I also tried things like changing camera bounds, world bounds, world size, but method above shows the most promise.The problem, however, is that the resize for some reason does not show until I click away from my browser tab and back. Calling game.width in the console yields 700 at all times, but it doesn't show it as such until tabbing out and back. On top of that, the contents of the game (floor, furniture, character) are scaled down when the game resizes, defeating the purpose. I don't understand why it would, since there's no scaling anywhere in my code. Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
in mono Posted September 25, 2015 Share Posted September 25, 2015 This is how we're doing it in one of our games:game.width = width;game.height = height;game.stage.width = width;game.stage.height = height;if (game.renderType === Phaser.WEBGL) { game.renderer.resize(width, height);}game.world.setBounds(0, 0, width, height);game.camera.setSize(width, height);game.camera.setBoundsToWorld();game.scale.setShowAll();game.scale.refresh();It's dealing more with resizing the browser window, but should be similar to your usage scenario. Hope it helps. MichaelD 1 Link to comment Share on other sites More sharing options...
MichaelD Posted September 25, 2015 Share Posted September 25, 2015 There is a function that does exactly that: http://phaser.io/docs/2.4.3/Phaser.ScaleManager.html#setGameSizegame.scale.setGameSize(700, 450); // et voila! Link to comment Share on other sites More sharing options...
bartk Posted September 25, 2015 Author Share Posted September 25, 2015 Michael, you're the man. That did exactly what I was looking for. Figured it'd be a case of knowing the right function Link to comment Share on other sites More sharing options...
bartk Posted September 25, 2015 Author Share Posted September 25, 2015 Now that I think about it, do you know of a convenient way to actually find out about such specific functions? I know about Phaser's documents, but actually finding what you need can be pretty tricky, especially if you don't exactly know how to solve problem #whichever. Link to comment Share on other sites More sharing options...
MichaelD Posted September 25, 2015 Share Posted September 25, 2015 I'm not sure there is an easy way for this (asking the forums here is actually the most convenient way), I am just searching the docs for whatever seems like it could do the trick, and if I'm not sure what it does I do a search "Phaser mysteryFunction" and usually posts from the forums or other tutorials come up. Good thing is that Phaser has been around for awhile and its becoming more popular by the day, this helps because more and more search results come up. Link to comment Share on other sites More sharing options...
drhayes Posted September 25, 2015 Share Posted September 25, 2015 I'm on OSX and I use this program called Dash. It's an offline documentation browser that has documentation for tons of things (HTML, JS, etc). Users can contribute docsets as well. There's a Phaser docset that's current to 2.4.3. Once I learned my way around Phaser and learned the biggish component parts (ScaleManager, Phaser.Input, Phaser.Time, etc) it got easier to guess where stuff like this is located. MichaelD 1 Link to comment Share on other sites More sharing options...
Recommended Posts