trying to check device orientation...

No worries.

The reason for all my questions is because it sounds to me like you’re trying to address a surface problem (your game doesn’t look right if user rotates the device) with a misguided approach (a popup) that’s probably going to annoy your users.  If your game actually has “visual issues”, as you called them, when the user rotates the device, then I think you have a much deeper problem in terms of how your game is set up and how you’re handling orientation changes, and I think you should focus on fixing that problem.  I realize you mentioned that you didn’t want to go into specifics, but it might be worth at least describing in a bit more detail what you’re facing.  Maybe the visual issues you’re having actually have an easy root cause fix, in which case you can avoid the ugly popup altogether.

  • Andrew

Yeah I can’t quite understand the issue here - if it’s set to Landscape only (properly) you don’t need to worry about what happens when the user rotates the device. Think Angry Birds - does that do anything if you rotate the device?

I dont know I have never played angry birds game. I thought you needed to specify in code your orientation? I know it is in the buildsettings but I thought that it was in there for simulating/development purposes. For the user to benefit from a device making orientation checks, I thought you had to specify that in code?

I don’t have a way to test this

function deviceOrientation ( event ) -- LINE BELOW CHECKS IF DEVICE IS ROTATED AWAY FROM LANDSCAPE POSITION         if event.type ==  "portrait" or "portraitUpsideDown" or "faceDown" then "applicationSuspend" else end end Runtime:addEventListener ( "orientation", deviceOrientation ) --LISTENER  

But, think this will work? :ph34r:

No, the orientation you specify in build.settings isn’t just for simulating/developing purposes, it actually determines what orientations are shown on the user’s device.  For most applications, you can just set these settings in build.settings and then never have to do anything in your code to get your orientation working correctly.

Can you copy/paste your build.settings file into this thread?  We can take a look and make sure you’ve set it up correctly to handle landscape-only orientation.

  • Andrew

Hmm…okay well here is my buildsettings file. What’dya think?

-- MY BUILD SETTINGS FOR "NAME OF GAME HERE" settings = {     orientation =     {         default = "landscapeRight",         supported =         {             "landscapeRight"         },     },     android =     {         versionCode = "1"     },     androidPermissions =     {         "android.permission.WRITE\_EXTERNAL\_STORAGE"     },     iphone =     {         plist =         {             UIPrerenderedIcon = true,             UIApplicationExitsOnSuspend = false,             UIStatusBarHidden = true,                         CFBundleIconFile = "images/iconMM.png",                         CFBundleIconFiles = {                                 "iconMM.png"                           },         },     }, }  

I also thought the above was for starting the game and after the game starts if a user tips their device a certain way the screen will automatically shift in the direction the user tipped/turned their device…I am wrong for thinking that?, or?..  :o

Hi there,

Your build.settings looks OK to me except for one thing: you’re using an old way of including the androidPermissions.  The new way is to have a table called usesPermissions within the android table.  Check out the sample here: http://docs.coronalabs.com/guide/distribution/buildSettings/index.html#androidsettings.

As for orientation, in build.settings, “default” controls what orientation the app will start in (like you said), and “supported” will ensure that the app only stays in one of the supported orientations.  You’ve done the right thing by setting both the default and supported orientations as landscapeRight,  This means that, no matter how the user orients the device physically, the display won’t change – the display will still be oriented landscapeRight.

You can actually see what this is like in the Corona Simulator.  While your app is running in the Simulator, click Hardware on the menu, then click Rotate Right or Rotate Left.  This simulates a user rotating their device to a different orientation, and you can see that it should be fine / no visual issues like you were worried about.

  • Andrew

You know…I never thought of turning the simulator itself… :blink:

That just cleared up everything lol…I tried running the simulator and when i use ROTATE LEFT or ROTATE RIGHT, the device rotates and everything rotates with it. I thought I had to code all that in…hmm, okay well thanks aukStudios. :slight_smile:

No problem, happy to have helped.  :-)

  • Andrew