Jump to content

centering canvas


Paul-Andre
 Share

Recommended Posts

You can use this to center your content:

 
this.game.stage.scale.pageAlignHorizontally = true;this.game.stage.scale.pageAlignVeritcally = true;this.game.stage.scale.refresh();

Although I think there's a minor typo in the source code. pageAlignVeritcally or pageAlignVertically?

Link to comment
Share on other sites

  • 6 months later...

I tried this code

this.game.stage.scale.pageAlignHorizontally = true;this.game.stage.scale.pageAlignVeritcally = true;this.game.stage.scale.refresh();

with or without "this", but it doesn't work for me as well.

 

Sorry for a noob question, but where do you put it exactly? I put it under function create(), but it doesn't center.

I tried to make it fullscreen and put the code under function create(), and it works. I wonder why I can't center the game.

Link to comment
Share on other sites

I found the solution.

 

Instead of using the code

this.game.stage.scale.pageAlignHorizontally = true;this.game.stage.scale.pageAlignVertically = true;this.game.stage.scale.refresh();

Use this one instead:

this.game.scale.pageAlignHorizontally = true;this.game.scale.pageAlignVertically = true;this.game.scale.refresh();
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...