I’ll be short.
build.settings:
settings = { orientation = { default = "portrait", supported = { "portrait", "portraitUpsideDown", "landscapeLeft", "landscapeRight" } } }
main.lua (short example version):
local borderLeft, borderTop = display.screenOriginX, display.screenOriginY local screenWidth, screenHeight = display.actualContentWidth, display.actualContentHeight local \_T = {} \_T.titleBar = display.newRect(borderLeft, borderTop, screenWidth, screenHeight\*0.08) \_T.titleBar:setFillColor(15) \_T.tabBar = display.newRect(borderLeft, borderTop + screenHeight\*0.08, screenWidth, screenHeight\*0.08) \_T.tabBar:setFillColor(0,200,255) function changeOrientation( mode ) if mode == "portrait" or mode == "portraitUpsideDown" then borderLeft, borderTop = display.screenOriginX, display.screenOriginY screenWidth, screenHeight = display.actualContentWidth, display.actualContentHeight \_T.tabBar:removeSelf(); \_T.tabBar = display.newRect(borderLeft, borderTop + screenHeight\*0.08, screenWidth, screenHeight\*0.08) \_T.tabBar:setFillColor(0,200,255) \_T.titleBar:removeSelf() \_T.titleBar = display.newRect(borderLeft, borderTop, screenWidth, screenHeight\*0.08) \_T.titleBar:setFillColor(15) elseif mode == "landscapeLeft" or mode == "landscapeRight" then borderLeft, borderTop = display.screenOriginX, display.screenOriginY screenWidth, screenHeight = display.actualContentHeight, display.actualContentWidth \_T.tabBar:removeSelf(); \_T.tabBar = display.newRect(borderLeft, borderTop + screenHeight\*0.08, screenWidth, screenHeight\*0.08) \_T.tabBar:setFillColor(0,200,255) \_T.titleBar:removeSelf() \_T.titleBar = display.newRect(borderLeft, borderTop, screenWidth, screenHeight\*0.08) \_T.titleBar:setFillColor(15) end end local function onOrientationChange( event ) changeOrientation( event.type ) end Runtime:addEventListener( "orientation", onOrientationChange )
The issue: Default orientation is portrait, so the pre-declared code defines the positioning of objects in portrait at startup. However if I start the app with my device in landscape, it will load the app with the pre-declared object positions and not the orientation declared by the changeOrientation function. Which makes it all look very weird, however as fast as I rotate my device it will check for the cases in changeOrientation and from there the app will work just as it should.
The top part of the picture is how it looks when starting the app in landscape, the bottom is how it actually looks normally:

Is there a way to make the app use the orientation cases in changeOrientation instantly at startup?
-Pierre