Canvas size less than 100%

0 favourites
  • 2 posts
From the Asset Store
100 Game Sound Effects
$2.40 USD
20% off
This sound pack comes with 100 high quality, ready-to-use sound effects for all kinds of games.
  • How do I get the exported game to show up as a percentage of the window width instead of defaulting to "full?"

    I want my canvas to be 53% of the width of the window, and to resize vertically, keeping the correct aspect ratio.

    I tried changing the code in the html file, but it doesn't want to listen - it just keeps resetting to full size.

    		jQuery(window).resize(function() {
    			var theCanvas = document.getElementById("c2canvas");
    			var theWidth = window.innerWidth * .53;
    			var theHeight = theWidth * 224/256;
    			
    			
    			cr_sizeCanvas(theWidth, theHeight);
    			theCanvas.setAttribute('width', theWidth);
    			theCanvas.setAttribute('height', theHeight);
    			document.write(window.innerWidth);
    			
    		});[/code:16x99oy0]
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Try using the Sytem object set WindowWidth width/2.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)