- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I created a menu for my game, so this menu can be displayed in landscape. I'm using the plugin Screen Orientation, in android works correctly.
How do I display this menu (made in Canvas + phaser js) is displayed only in landscape on the iPhone too ?!
* excuse the horrible English
- Tags:
- HTML5
- Intel® XDK
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That plugin seems to work differently on iOS than it does on Android. Here's some sample code that might help you figure it out:
app.testToggleOrientation = function() { "use strict" ; var fName = "toggleOrientation():" ; app.consoleLog(fName, "entry") ; var str = "" ; var screenOrientation = "unknown" ; if( window.cordova ) { try { if( cordova.platformId.match(/ios/i) ) { screenOrientation = screen.orientation ; } else if( cordova.platformId.match(/android/i) ) { screenOrientation = screen.orientation.type ; } else { screenOrientation = "unknown" ; } if( screenOrientation.match(/landscape/i) ) { screenOrientation = "portrait" ; screen.lockOrientation(screenOrientation) ; } else if( screenOrientation.match(/portrait/i) ) { screenOrientation = "landscape" ; screen.lockOrientation(screenOrientation) ; } else { screenOrientation = "unlocked" ; screen.unlockOrientation() ; } str = "try succeeded, screen orientation set to: " + screenOrientation ; app.consoleLog(fName, str) ; } catch(e) { str = "try failed: " + e ; app.consoleLog(fName, str) ; app.alert(str) ; } } // app.flashBackground("#"+Math.floor(Math.random()*16777215).toString(16), 0) ; app.consoleLog(fName, "exit") ; } ; app.windowEventOrientationChange = function() { "use strict" ; var fName = "windowEventOrientationChange():" ; var str = "" ; var screenOrientation = "unknown" ; if( window.cordova ) { if( cordova.platformId.match(/ios/i) ) screenOrientation = screen.orientation ; else if( cordova.platformId.match(/android/i) ) screenOrientation = screen.orientation.type ; } str = "Screen orientation is: " + screenOrientation ; app.consoleLog(fName, str) ; // app.alert(str, 1000) ; } ; window.addEventListener("orientationchange", app.windowEventOrientationChange) ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
how I implement?! can a help me?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Felipe -- the code I provided is quite clear on how to handle the differences between iOS and Android. Please read the code.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page