Migration x(y)Reference -> anchorX(Y) not interchangeable

You could try adding this line to your config.lua where you define the width and height:

graphicsCompatibility = 1

And see if that helps things.  However this is not a long term solution.  You should learn the new techniques of Graphics 2.0.  This guide will help you convert it to the new way.  http://docs.coronalabs.com/guide/graphics/migration.html

Rob

yes Rob , i have tried to run this code in compatibility mode .but it is not working, So let me try to understand the migration of reference point to anchor point .

Thank you 

Hi alexandr

Try this function for convert xReference and yReference to anchorX and anchorY

I am sure it will work for you.

local min, max = math.min, math.max

 

function setAnchorCoordinates( object, xReference, yReference )

  object.anchorX = min( 1, max( 0, (xReference / object.width)+.5))

  object.anchorY = min( 1, max( 0, (yReference / object.height)+.5))

end

 

Regards,

 

Sptechnolab Team

You can always do it as a mixin if it is just the setReferencePoint() method you are after (probably not wise to tinker with the display.group prototype …) e.g.

-- setreference point decorating. display.newLine(0,240,320,240):setStrokeColor( 0,1,0 ) display.newLine(160,0,160,480):setStrokeColor( 0,1,0 ) local r = display.newRect(0,0,100,100) r:setFillColor( 0,0,1 ) r.x,r.y = 160,240 r:toBack() r:setStrokeColor(1,1,1) r.strokeWidth = 1 function decorateReference(obj) display.TopLeftReferencePoint = 0 -- Define the required constants. These are done this way to make display.TopCenterReferencePoint = 1 -- the calculation easy. display.TopRightReferencePoint = 2 display.CenterLeftReferencePoint = 3 display.CenterReferencePoint = 4 display.CenterRightReferencePoint = 5 display.BottomLeftReferencePoint = 6 display.BottomCenterReferencePoint = 7 display.BottomRightReferencePoint = 8 obj.setReferencePoint = function(self,refPoint) obj.anchorX = refPoint % 3 / 2 obj.anchorY = math.floor(refPoint / 3) / 2 end return obj end r = decorateReference(r) -- you can chain this e.g. r = decorateReference(display.newRect()) r:setReferencePoint(display.CenterRightReferencePoint)

Hi
 
Thanks to everyone, especially grateful to SP Technolab your method work perfectly. I think it should be included in the migration guides for those who want quickly move for Graphics 2.0.
 
Best regards
Alexander