Jump to content

Forcing Landscape Mode Through CSS Rotation


Puzz3l
 Share

Recommended Posts

I want to have my game only playable in landscape, so I added the following code to my game.js

 

	// Autorotate screen	function reorient(e) {		var portrait = (window.orientation % 180 == 0);		document.getElementById('game_div').style["-webkit-transform"] = portrait ? "rotate(90deg) translate(248px, 248px)" : "";	}	window.onorientationchange = reorient;	window.setTimeout(reorient, 0);

Unfortunately, now if I try and use buttons/controls while holding the phone portrait, things get wonky. Buttons don't press and the input is clearly being messed with. How do I resolve this?

 

Link to comment
Share on other sites

  • 2 years later...
 Share

  • Recently Browsing   0 members

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