Jump to content



Recommended Posts

Hi :)


So I have in my phaser game a text element (DOM).

When I set the scale mode of my game to SHOW_ALL and set it to fit the screen size, my canvas changes perfectly but the html element doesn't. 


I am trying for a while now to change the element scale according to my phaser canvas scale so the text will always stay at the position I want it to be and it's size to fit too, however, I can't find how to do it.

Of course, I need to the font size to change too.


any help?


Thank you :)


Link to comment
Share on other sites

I guess you have good motives not to directly integrate your text as a Phaser text component, but obviously it makes things harder. However I think you could use plain javascript or even Jquery to listen to the window-resizing event and modify your text dimensions when triggered : 


$(window).resize(function(){window.resizeGame();});function resizeGame() {  // Refresh the game size  game.scale.setShowAll();  game.scale.refresh();  // Resize your DOM elements here}
Link to comment
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.

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.


  • Recently Browsing   0 members

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