Month: December 2016

For a few months and in my Udemy lessons, I've been detecting mobile devices by measuring the width of the screen. For a while this worked, but I've now found it to be ineffective. Sometimes a smaller desktop or laptop screen will show up as a mobile device.
Here is the original Start for desktop/mobile snippet
var game;
window.onload = function()
{
if (screen.width>1500)
{
game=new Phaser.Game(480,640,Phaser.AUTO,"ph_game");
}
else
{
game=new Phaser.Game(window.innerWidth,window.innerHeight,Phaser.AUTO,"ph_game");
}
game.state.add("StateMain",StateMain);
game.state.start("StateMain");
}
And here is the Start for desktop/mobile update
isMobile=navigator.userAgent.indexOf("Mobile");
console.log("isMobile="+isMobile);
if (isMobile==-1) {
//desktop lapto