Yanifska Posted March 22, 2015 Share Posted March 22, 2015 Hi,I am trying to use the following line - before game initialization - to detect if the game will be running on desktop and set a specific size. if(Phaser.Device.desktop)This return always false.Please show me the right way.Thank youYaniv Link to comment Share on other sites More sharing options...
seemly Posted March 22, 2015 Share Posted March 22, 2015 Bit of an obvious question, but what device are you testing on?Do you have any kind of emulation mode turned on? Link to comment Share on other sites More sharing options...
Yanifska Posted March 22, 2015 Author Share Posted March 22, 2015 I am not sure I follow...I am testing on desktop ( chrome, IE, firefox) and I get a false result where I expect true, so the game could be set at a specific size.The game is working (kind of) fine on mobile devices. My trouble is how to detect when I am on desktop, before initialising the game.I thought it was something basic....Thank you anyway Link to comment Share on other sites More sharing options...
corpsefilth Posted March 22, 2015 Share Posted March 22, 2015 Hi, if you are using only one state in your app, try this in the create function: if(this.game.device.desktop) { // desktop view - desktop code herethis.scale.pageAlignHorizontally = true;//this.scale.setScreenSize(true); } else { // game sacle: min: 480X260, max: 1026X768 - non-desktop code herethis.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;this.scale.minWidth = 568;this.scale.minHeight = 600;this.scale.maxWidth = 2048;this.scale.maxHeight = 1536;this.scale.forceLandscape = true;this.scale.pageAlignHorizontally = true;this.scale.setScreenSize(true);} I'm also assuming that you are using this line as your game object, mainly the "game" variable, as I am using this.game above:var game = new Phaser.Game(window.innerWidth, window.innerHeight, Phaser.AUTO, ''); I used that line on my very first state of my game, I am using many states in my game to handle the load screen, menu screen, level 1 screen etc.So I added the above code in my "Boot" state, which runs first than any other state. Also remember that every state can has the same 'perload()', 'create()', and 'update()' functions among others. Let me know if this helps. Link to comment Share on other sites More sharing options...
Yanifska Posted March 23, 2015 Author Share Posted March 23, 2015 corpsefilth, I am using the mobile templatecurrently I have a code close to what you provided in my boot.jsso I guess it is the right way to do itSomehow I thought it was better to check and set the size before the game initialisation. Link to comment Share on other sites More sharing options...
Recommended Posts