Hester Posted July 8, 2016 Share Posted July 8, 2016 Hello I plan to make doodle jump game but it required the phone to orientate in order to control the doodle. I use Game Maker to develop it. Can the mobile web browser support it? I read somewhere only hybrid app can detect the phone orientation but mobile web browser cant support it. Is it true? I need to be sure about it Quote Link to comment Share on other sites More sharing options...
labrat.mobi Posted July 8, 2016 Share Posted July 8, 2016 It is possible with web browser. You need to listen for deviceorientation event. https://developer.mozilla.org/en-US/docs/Web/API/Detecting_device_orientation Example game: http://goldenratio.github.io/candy-jump-saga/ Check it out in mobile browser (Chrome/Android) Edit: I don't know about GameMaker, but this can be done with simple vanilla javascript. Quote Link to comment Share on other sites More sharing options...
mattstyles Posted July 9, 2016 Share Posted July 9, 2016 All browsers support `deviceorientation`, but not very well. It only fires after the event, which might be fine for what you want (mostly, afterwards is useless and you really want it before). Sometimes it can take a while for the browser to report the orientation change too, again, less than ideal. Rarely it wont fire at all, usually as a result of multiple rapid orientation changes although this is an unusual edge-case. Google are generally far more supportive of the web platform so you might find modern Android devices actually handle this event better than iDevices, the device orientation, and lack of locking support, is a real footgun for the mobile web. Quote Link to comment Share on other sites More sharing options...
Fatalist Posted July 9, 2016 Share Posted July 9, 2016 You can also listen to resize event - if innerWidth > innerHeight - it's horizontal. 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.