Sign in to follow this  
slingchilders

Resizing the canvas itself, not the game

Recommended Posts

How would I handle resizing the canvas? I try doing this on window resize, but the game is stretched very weirdly. I don't want to scale the game, just show more of it when the window and the game area becomes bigger/smaller?

            this.game.width = this.canvasWidth;
            this.game.height = this.canvasHeight;
            this.game.canvas.width = this.canvasWidth;
            this.game.canvas.height = this.canvasHeight;
            this.game.renderer.resize(this.canvasWidth , this.canvasHeight);
            this.game.scale.refresh();
 
// If i leave just this the game behaves as expected when resizing from bigger view to smaller, but when the game is loaded in a small window, and then resized to a bigger one, the canvas has margins set to never exceed the initial size, how can I fix it?
this.game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.