I’ve got a simple exercise I’m working on that should rotate a word when you flip the device from portrait to landscape. It works perfectly in the Corona Simulator. It also works built on an Android device. It doesn’t however, work on my iPhone 5C running iOS 7.1.2.
When I flip the phone, instead of rotating 90 degrees, the phone’s built-in auto rotation rotates the text 90 degrees and then the code I wrote rotates it another 90 degrees. I’m thinking this may be a build.settings issue? I don’t have a build.settings file in the project yet.
Again, this DOES work on the Android phone I’ve been working with…just not my iPhone.
Here’s the code I wrote:
local portrait = display.newText(“Portrait”,0 ,0 , native.systemFont, 24)
local landscape = display.newText(“Landscape”,0 ,0 , native.systemFont, 24)
portrait.x = display.contentWidth/2
landscape.x = display.contentWidth/2
portrait.y=display.contentHeight/2
landscape.y = display.contentHeight/2
portrait:setTextColor(12,200,73)
landscape:setTextColor(200,12,73)
portrait.alpha =1
landscape.alpha =0
local function onOrientationChange(event)
if(event.type ==“landscapeRight” or event.type == “landscapeLeft”) then
local newAngle = landscape.rotation - event.delta
transition.to(landscape , {time =1000, rotation = newAngle})
transition.to(portrait, {rotation=newAngle})
portrait.alpha =0
landscape.alpha = 1
else
local newAngle = portrait.rotation - event.delta
transition.to(landscape, {rotation = newAngle})
transition.to(portrait, {time=1000, rotation = newAngle})
portrait.alpha =1
landscape.alpha = 0
end
end
Runtime:addEventListener(“orientation”, onOrientationChange)