• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Legacy GM HTML5/Auto Resize Canvas Based On Browser Dimensions?

J

JeZxLee

Guest
Hi,

So I have an HTML5 version of my game live on my website.
It works 100%, but there is one thing that is bothering me about it:
How can I make the game's canvas resize(maximize) automatically(while maintaining aspect ratio)
based on browser's dimensions?

There must be some way to do the above?
Because my game will be tiny on a new 4k monitor.
I want the game to fill the browser window.
We need a GameMaker Language script command, our game is 100% script based.

Any ideas?
Thanks!

Click below URL link to play the current HTML5 version of our game:
http://opentetris.com/files/TAA/HTML5/index.html
 

MrDave

Member
What happens when you use full screen? That might be a better solution.

It is possible with Javascript but then you would have to maintain code in different places and it would become a headache.

You would have to do something like this (this is jQuery):

Code:
<script>
$('#canvas').css('width', '100%');
$(window).resize(function(){
     $('#canvas').height($('#canvas').width() / 1.8);
});
</script>
 
Top