cheapdevotion Posted September 17, 2013 Share Posted September 17, 2013 Hey Guys,Coming from Unity, to zoom the camera on a scene I could simply change the orthographic size, but some of the simple practices are lost on me with Phaser. What I am trying to do is load a tilemap, but actually set the camera rect to be a small portion of the screen. Once the camera rect is set, I would like to scale the screen to fit the browser window, so I essentially zoom into a certain part of the tilemap. I have tried setting the game.camera.width and game.camera.height. I have also tried using the game.camera.setSize() and they don't seem to have an effect. What am I doing wrong? Here is what my code looks like: (function () {var game = new Phaser.Game(640, 480, Phaser.AUTO, '', { preload: preload, create: create, update: update });function preload() { game.load.tilemap('map', 'assets/tileset1.png', 'assets/map.json', null, Phaser.Tilemap.JSON); game.stage.scaleMode = Phaser.StageScaleMode.EXACT_FIT; game.stage.scale.refresh();}var map;function create() { map = game.add.tilemap(0, 0, 'map'); game.camera.width = 320; game.camera.height = 200;}})(); Link to comment Share on other sites More sharing options...
rich Posted September 18, 2013 Share Posted September 18, 2013 You're not doing anything wrong, you just can't change the camera dimensions - they match the game size at the moment. What you could try doing though is scaling either the tilemap or the Stage on which everything lives. The tilemap is rendered into a container which can be scaled up/down. I expect this will blow out the tile collision though, but still might be worth trying. Link to comment Share on other sites More sharing options...
Rex Rhino Posted November 4, 2013 Share Posted November 4, 2013 You're not doing anything wrong, you just can't change the camera dimensions - they match the game size at the moment. What you could try doing though is scaling either the tilemap or the Stage on which everything lives. The tilemap is rendered into a container which can be scaled up/down. I expect this will blow out the tile collision though, but still might be worth trying. I am trying to do something similar to this... In this example, how would you scale the Stage in which everything lives? Thanks for your help! Link to comment Share on other sites More sharing options...
ForgeableSum Posted May 3, 2015 Share Posted May 3, 2015 You're not doing anything wrong, you just can't change the camera dimensions - they match the game size at the moment. What you could try doing though is scaling either the tilemap or the Stage on which everything lives. The tilemap is rendered into a container which can be scaled up/down. I expect this will blow out the tile collision though, but still might be worth trying.I don't quite understand. If you can't change the camera dimensions, what is the point of the setSize method and height/width properties? Zedronar 1 Link to comment Share on other sites More sharing options...
Zedronar Posted May 12, 2015 Share Posted May 12, 2015 I don't quite understand. If you can't change the camera dimensions, what is the point of the setSize method and height/width properties? Same question here. Having the same trouble. Link to comment Share on other sites More sharing options...
rich Posted May 12, 2015 Share Posted May 12, 2015 So you can tell if something is within the camera bounds or not. Which is impossible if the camera doesn't have a size. Link to comment Share on other sites More sharing options...
Recommended Posts