Murrayhill

Scaling my entire game to fit window size?

Recommended Posts

Hi, I have a side scroller which is using a 16x16 tiles that comes out pretty tiny on my monitor, so I would like to be able to scale the game up, kind of like when you zoom in on chrome :D

I'm aware of this post, but nothing on there is helping me.

I know you can use the example.smoothed = false; for crisp, which isn't a problem it's scaling the entire game up that is a problem.

Whenever I try adding any of this to the code it breaks, and says " SHOW_ALL is undefined" 

game.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL; //resize your window to see the stage resize toogame.stage.scale.setShowAll();game.stage.scale.refresh();

 

Source code: http://pastie.org/10747979

Share this post


Link to post
Share on other sites
2 hours ago, shohan4556 said:

    var game = new Phaser.Game(window.innerWidth * window.devicePixelRatio, window.innerHeight * window.devicePixelRatio, Phaser.CANVAS, 'game');

Try this. 

That just changes the canvas size, and does not scale the actual tileset or sprite.

Sorry if i was vague, but I was trying to make it so the sprite, and tilset were scaled up to the window size.

Go from this to this. I would just need to smooth out the tileset and sprite for it to look crisp, but is there any code that can do what I just showed you? (Just enlarging it.)

Share this post


Link to post
Share on other sites

thats way to much work, all you do is:
game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;

You wrote StageScaleMode instead of ScaleManager, the post you were reading is old, always check the documentation for updates.

Share this post


Link to post
Share on other sites
2 hours ago, Murrayhill said:

Uhh.. What do you mean a group?

var map = game.add.sprite(x,y,mapKey);
var player1 = game.add.sprite(x,y,Player1Key);
var player2 = game.add.sprite(x,y,Player2Key);

var sprites = game.add.group();

sprites.add(map);
sprites.add(player1);
sprites.add(player2);

sprites.scale.set(0.8);

The above code will scale down all the sprites to 80%. Not sure if that's what you want.

 

EDIT: Just noticed you're asking for scaling to window screen. The code I wrote is for zoom. Thought you were talking about that kind of scale.

Share this post


Link to post
Share on other sites
17 hours ago, rgk said:

thats way to much work, all you do is:
game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;

You wrote StageScaleMode instead of ScaleManager, the post you were reading is old, always check the documentation for updates.

Yes! That sort of works, well it does, but for some reason the canvas is continue to enlarge until it's all the way zoomed in.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.