Hi,
I am facing a problem that when trying to center a DisplayObject after device rotation.
The objects starts out in the Center of the screen, but after I rotate the Device to landscape mode, the x and y of the object still seemed to be referencing the previous orientation, and the object doesn’t center in landscape mode.
Rotating it back to Portrait or PortraitUpsideDown mode and the object centers.
Here’s my code:
[lua]local redMarble = display.newImage(“redmarble.png”)
– setup their starting positions
function placeMarbles()
local screenWidth = display.contentWidth
local screenHeight = display.contentHeight
transition.to(redMarble, {timer=1000, x=(screenWidth/2), y=screenHeight/2})
end
function onOrientationChange( event )
print ("Orientation: ", event.type)
print ("ScreenWidth: ", display.contentWidth)
print ("ScreenHeight: ", display.contentHeight)
placeMarbles()
end
– Setup Event Listener
Runtime:addEventListener(“orientation”, onOrientationChange)
placeMarbles()[/lua]
Thank you. [import]uid: 190205 topic_id: 32909 reply_id: 332909[/import]