Sturb Posted April 12, 2016 Share Posted April 12, 2016 Hey guys, I'm not sure if this is a canvas or scale manager things but what I trying to achieve is some way to offset the game screen after scaling it. I need to support 16:9 and 4:3 aspect ratios. I have the scaling part all done and working, my issue is that I need to apply my calculated offsets to the game screen so the left and right edges are pushed out of view when in a 4:3 ratio. This is what I'm currently getting when in 4:3. The darker areas would be out of view, or off screen. This is what I'm looking to achieve when in 4:3. The darker areas would be out of view, or off screen. Any help would be appreciated Link to comment Share on other sites More sharing options...
Tom Atom Posted April 12, 2016 Share Posted April 12, 2016 Hi, I found very beneficial to set 0,0 in the middle of the screen in my games: // set camera this.world.setBounds(-this.game.width / 2, -this.game.height / 2, this.game.width, this.game.height); this.camera.focusOnXY(0, 0); all objects are then placed relative to 0,0, when scaling, center remains in center. There are games where I am setting center point at different places - I was working on game, where objects are falling down (kind of tetris / match-3) and there it was advantageous to place 0,0 at bottom center. But setting center where I need it is key for me. drhayes and Sturb 2 Link to comment Share on other sites More sharing options...
Sturb Posted April 15, 2016 Author Share Posted April 15, 2016 Thanks for the snippet. We ended up going with a CSS solution, however knowing that you can offset the world like this could come in handy. Link to comment Share on other sites More sharing options...
Recommended Posts