When I create an image after the device’s orientation has changed (i.e., starting from portrait and changing to landscape, or starting from landscape and switching to portrait), the scale of the image will be distorted, as shown in the attached image (starting orientation on left, changed orientation on right). If the device is switched back to its starting orientation again, newly created images will have the correct scale.
On the left is the image in the starting orientation, and on the right is the image after the device has been rotated.
The thing that’s really getting to me is that I’ve only observed this issue on one device (2012 Nexus 7). Images are displayed correctly on the simulator, an iPad mini, two other Android tablets, and four Android phones.
Sample project which reporoduces the issue as is follows. The image is a 100x100 px square.
main.lua
display.setDefault( "background", 80/255 ) squareImg = display.newImageRect("icon1.png", 300, 300) squareImg.x = 250 squareImg.y = 250 local function onOrientationChange( event ) if squareImg ~= nil then display.remove(squareImg) squareImg = nil end squareImg = display.newImageRect("icon1.png", 300, 300) squareImg.x = 250 squareImg.y = 250 end Runtime:addEventListener( "orientation", onOrientationChange )
config.lua
application = { content = { scale = "none", fps = 60, } }
build.settings
settings = { orientation= { default = "portrait", supported = { "portrait", "portraitUpsideDown", "landscapeRight", "landscapeLeft", } }, }
If anyone could at least point me in the right direction on how to diagnose this problem, I’d greatly appriciate it.