rhennig Posted September 24, 2018 Share Posted September 24, 2018 Hello! I'm having some troubles positioning objects on the screen of my mobile device using Cordova... I'm getting the screen height with: totalHeight=this.sys.game.config.height/window.devicePixelRatio; But when I try to put my object on the bottom of the screen with: ground.create(totalwidth/2, totalHeight, 'ground'); It works perfectly on the browser but on the mobile device it is not totally on the bottom (maybe someting like 80%~90% from the bottom), and I'm not getting why (I've tryed to change the setOrigin value but doesnt fixed the problem)... Is there something that I'm missing? Thanks in advance! Link to comment Share on other sites More sharing options...
prob Posted September 24, 2018 Share Posted September 24, 2018 I'd suggest checking your console for the Cordova build to see what the specs are for the actual Phaser canvas element. Are you using any plugins for the statusbar? Also, with the recent fix to the game resolution, you can set the pixel ratio in the game config (resolution: window.devicePixelRatio) and not worry about it after that, and just use this.sys.game.config.height/width. Link to comment Share on other sites More sharing options...
rhennig Posted September 26, 2018 Author Share Posted September 26, 2018 Hi, no, I'm not using any plugins. It's just a simple test. To clarify, this is how the code runs with cordova on the browser (cordova run browser). Using this code to set the ground position: ground.create(totalwidth/2, totalheight, 'ground').setOrigin(0.5, 1); And this is the same code on the device. As you can see there is a blank space below the "ground". Link to comment Share on other sites More sharing options...
Budda Posted September 27, 2018 Share Posted September 27, 2018 There's a possible suggested solution to a similar issue on https://stackoverflow.com/questions/36385665/phonegap-cordova-black-status-bar-on-bottom-after-fullscreen Link to comment Share on other sites More sharing options...
jamespierce Posted September 27, 2018 Share Posted September 27, 2018 Hmm that's weird I've just recently ported several of my Phaser games to Android with the help of Cordova and I didn't run into this issue. totalHeight=this.sys.game.config.height/window.devicePixelRatio; I think this is why the position is different because you take the devicePixelRatio into account for your in-game positions. However your game world should be independent of the device's screen size. If you simply use config.height it should work. You want to take the devicePixelRatio into account for your game scaling. I'm answering you because by coincidence I've just posted an answer here where I explain how I scale my games for mobile - and it is working perfectly for me with Cordova, as well: Link to comment Share on other sites More sharing options...
Recommended Posts