According to API doucmentation, changing anchorX and anchorY will not affect position of a displayobject.
I added an image with display.newImageRect() and set anchorX = 0 and anchorY = 1. After placing the image with x & y coordinates as I want it I change anchorY = 0.5 to enable me to center other objects with this image.
But to my surprise, the image moves to the position as if I have set anchorY = 0.5 before setting coordinates.
Using Corona Version 2014.2171 (2014.2.8) and new Composer scenes.
local myImage function scene:create( event ) local sceneGroup = self.view myImage = display.newImageRect("images/myimage.png", 235, 180); myImage.anchorX = 0; myImage.anchorY = 0.5; sceneGroup:insert(myImage); myImage.x = 5; myImage.y = display.contentHeight - 50; end function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Called when the scene is still off screen (but is about to come on screen). elseif ( phase == "did" ) then -- Called when the scene is now on screen. -- Insert code here to make the scene come alive. -- Example: start timers, begin animation, play audio, etc. -- Game scene is visible, start game round... myImage.anchorY = 0.5; -- This moves the image when changing anchor position end end
Any ideas?