Our app supports all 4 orientations, and generally that works for us.
However we've just been trying to fix an orientation bug, and we don't think it's something that we can fix.
The Vungle ad seems to block the corona app from receiving resize events. This causes a problem if for instance:
- User is playing game in portrait.
- Ad starts - the ad is currently a landscape video but is being shown in portrait mode (e.g. black borders above/below).
- User rotates device to make the video ad full screen, video rotates as expected.
- When video ends, objects in the game are not positioned correctly.
I tried manually calling our orientation handler, and system.orientation is correct. HOWEVER, all of the display variables (display.contentWidth, display.contentHeight, display.screenOriginX, display.screenOriginY etc) are incorrect. They are still showing as portrait values even though the device is now in landscape. If we now rotate back to portrait that fixes it, but that is not a real fix. We've done this as a temporary measure:
if vungleStartOrientation == "landscapeLeft" or vungleStartOrientation == "landscapeRight" then if system.orientation == "portrait" or system.orientation == "portraitUpsideDown" then display.contentWidth, display.contentHeight = display.contentHeight, display.contentWidth display.screenOriginX, display.screenOriginY = display.screenOriginY, display.screenOriginX display.viewableContentWidth, display.viewableContentHeight = display.viewableContentHeight, display.viewableContentWidth end elseif vungleStartOrientation == "portrait" or vungleStartOrientation == "portraitUpsideDown" then if system.orientation == "landscapeLeft" or system.orientation == "landscapeRight" then display.contentWidth, display.contentHeight = display.contentHeight, display.contentWidth display.screenOriginX, display.screenOriginY = display.screenOriginY, display.screenOriginX display.viewableContentWidth, display.viewableContentHeight = display.viewableContentHeight, display.viewableContentWidth end end
Where vungleStartOrientation is a variable which stores the system.orientation before the ad starts playing.
This fix would be ok, however there is one additional problem... faceUp and faceDown orientations.
If the user does this...
Game is in portrait.
Rotate device to view in landscape.
Put device flat on surface while video is still playing - device is now in faceUp orientation.
Ad ends - return to game.
...the device should now be in a landscape orientation, but my if statements won't be triggered because vungleStartOrientation is "portrait" and system.orientation is now "faceUp". It has no way of knowing the game also rotated to landscape in between.
If the resize event was being triggered, I could use something like this:
if display.contentWidth < display.contentHeight then isLandscape = true end
...but it doesn't, so I can't.
Can anyone from Corona or Vungle make any suggestions or acknowledge this post please?