1-800-STAR-WARS Posted May 13, 2016 Share Posted May 13, 2016 Hi all, I have a game built in landscape orientation, but there is a lot of dead space around the edges - ie the game elements are all in the centre, and around 40% of the game (ie 20% on each side) is essentially background details that aren't necessary for the game to function. I was wondering if it would be possible to essentially trim the edges off the game while maintaining the central elements when the game is in portrait mode? I was thinking this could be achieved using CSS alone by scaling up the canvas or container element beyond the width of the viewport but I've had no success with that so far, though I reckon it's still possible somehow. Maybe there are some options from within Phaser by resizing the game, if so is there a way to keep the game centred? Cheers! Link to comment Share on other sites More sharing options...
kevdude Posted May 16, 2016 Share Posted May 16, 2016 function resize_game(){ game.scale.setGameSize(window.innerWidth, window.innerHeight); } Then in the index.html: <body onresize = "resize_game()"> </body> This should simply resize the game area. Link to comment Share on other sites More sharing options...
1-800-STAR-WARS Posted June 1, 2016 Author Share Posted June 1, 2016 Thanks kevdude, I'd worked it out in the end - had never noticed the 'setMinMax' function in the scaling manager before, so that in combination with resizing the game and offsetting the world co-ordinates to keep things centred did the trick. Cheers. Link to comment Share on other sites More sharing options...
Recommended Posts