k0rs4r Posted August 28, 2013 Share Posted August 28, 2013 (edited) Hi guys!I'm complete my first game - Airport Control.And now i have BIG problem. I wanna ask:How i can fit my game to WHOLE screen on android? Except status bar, of course. My target browsers: Default and Chrome.This picture to explain what i want: As you understand, for this purpose i need to know size of window without address bar. window.outerHeight works good only in Default not in Chrome. And any other properties works ugly..But devices as many as many resolutions in world How do you solve this problem???Maybe you can share your own code or share link to the game when work good on all resolution on android devices? This is code i'm use right now. Works good in default and emulator, not work in Chrome. I don't know about real devices...width = window.innerWidth;if(navigator.userAgent.indexOf('Chrome') > -1) height = window.outerHeight;else if(navigator.userAgent.indexOf('Mozilla/5.0') > -1) height = window.outerHeight/window.devicePixelRatio;stage.canvas.style.width = width+'px';stage.canvas.style.height = height+'px';setTimeout(scrollTo(1,1),1);Thanks! Edited August 28, 2013 by k0rs4r Quote Link to comment Share on other sites More sharing options...
Chris Posted August 28, 2013 Share Posted August 28, 2013 I personally don't own any android device, but give this a try: I assume you have just a canvas tag inside your body container and want to have it full-screen. CSShtml, body{ height: 100%;}body{ padding: 0;}JS(function(){ 'use strict'; var c; c = document.getElementsByTagName('canvas')[0]; c.width = window.innerWidth; c.height = window.innerHeight; window.scrollTo(0,0); window.scrollTop = window.scrollY = window.scrollLeft = window.scrollX = 0;})(); k0rs4r 1 Quote Link to comment Share on other sites More sharing options...
k0rs4r Posted August 28, 2013 Author Share Posted August 28, 2013 Nice try =)But not exact.Its return full resolution of screen, and android have status bar(with different size on different devices) and button bar(on some devices).Sooo...it's works but not as expect...I'm explain..Technically i can't get full screen, status bar always on screen =( Any other ideas ? How developers support his game on android? For example SoftGames always tested games on android, but i don't find any themes on forum about scaling canvas game on android to screen. Maybe I do not know something important and obvious? Quote Link to comment Share on other sites More sharing options...
alex_h Posted August 28, 2013 Share Posted August 28, 2013 If you search for either fullscreen or full screen there have been a few discussions about this kind of thing in the past. In particular this one might help http://www.html5gamedevs.com/topic/762-how-to-hide-address-and-status-bars-on-mobile/ k0rs4r 1 Quote Link to comment Share on other sites More sharing options...
Chris Posted August 28, 2013 Share Posted August 28, 2013 Well, then lets grab window.innerWidth and window.innerHeight instead of screen.width and screen.height. I've updated my example above. k0rs4r 1 Quote Link to comment Share on other sites More sharing options...
k0rs4r Posted August 31, 2013 Author Share Posted August 31, 2013 Thanks guys!window.innerWidth & window.innerHeight is good approach! Now it works, but when i try it before this not work, strange =)Later i'm post my code for future generations ;D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.