Jump to content

Display game when loaded and centered


frenetikm
 Share

Recommended Posts

Hi,

 

I'm making a game, and in my boot.js file I'm doing:

this.scale.pageAlignHorizontally = true;this.scale.pageAlignVertically = true;

for display in center of the page.

 

The problem is when the page load, I see the game at top left of the page for less than a second, and after in the center...

 

 

Can somebody tell me what is the cleanest way to avoid this ? (show the game only after it has been centered)

 

Link to comment
Share on other sites

I would set the canvas or the DOM element containing the canvas to display:none; and then in the js do something like this:

if (this.scale.pageAlignHorizontally && this.scale.pageAlignVorizontally) {    document.getElementById("DIVcontainingGame").style.display = "block";}
Link to comment
Share on other sites

@Skeptron: the purpose was to keep the alignment with Phaser, if I do it via CSS where is no interest to keep this functions in my code

 

@vez: thanks, I think I'll do it like this way, I hoped a cleanest way

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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