Anchor Points? "Use anchor points instead"

– Declare the visible width and height of the screen as constants

_W = display.viewableContentWidth

_H = display.viewableContentHeight

local background = display.newRect(0, 0, 320, 480)

background:setFillColor(255,255,255)

local jump = display.newImage(“images/foo.png”)

jump:setReferencePoint(display.CenterReferencePoint)

jump.x = _W * 0.5

local bar = display.newImageRect(“jump.png”)

I get the error, “Use anchor points instead.”

The Reference Points are deprecated.

http://docs.coronalabs.com/api/type/DisplayObject/setReferencePoint.html

There you can learn how to use the new anchor things

1 Like

I know that, but how would you fix the code? =\

Oh sorry, Well the center of the object is anchorX=0.5 and anchorY=0.5
So u could do
jump.anchorX=0.5
jump.anchorY=0.5

But I believe the center is the default anchor when you create an object. At least that’s what I read on the link I gave you. So if u wanna set the anchors to the center just create it and that’s it.

I’m not sure if that’s what you’re trying to do.

Edit: to clarify things a bit more, remove this line jump:setReferencePoint(display.CenterReferencePoint) and that should fix it.

Ahh! Edit: to clarify things a bit more, remove this line jump:setReferencePoint(display.CenterReferencePoint) and that should fix it. That was what i needed, thanks! :slight_smile:

No problem :smiley: glad i could finally give something back to the community lol 

Just jumping in here with a suggestion.  Corona’s sample code uses these variables for anchors (easier to remember)

– Define reference points locations anchor ponts
local TOP_REF = 0
local BOTTOM_REF = 1
local LEFT_REF = 0
local RIGHT_REF = 1
local CENTER_REF = 0.5

The Reference Points are deprecated.

http://docs.coronalabs.com/api/type/DisplayObject/setReferencePoint.html

There you can learn how to use the new anchor things

I know that, but how would you fix the code? =\

Oh sorry, Well the center of the object is anchorX=0.5 and anchorY=0.5
So u could do
jump.anchorX=0.5
jump.anchorY=0.5

But I believe the center is the default anchor when you create an object. At least that’s what I read on the link I gave you. So if u wanna set the anchors to the center just create it and that’s it.

I’m not sure if that’s what you’re trying to do.

Edit: to clarify things a bit more, remove this line jump:setReferencePoint(display.CenterReferencePoint) and that should fix it.

Ahh! Edit: to clarify things a bit more, remove this line jump:setReferencePoint(display.CenterReferencePoint) and that should fix it. That was what i needed, thanks! :slight_smile:

No problem :smiley: glad i could finally give something back to the community lol 

Just jumping in here with a suggestion.  Corona’s sample code uses these variables for anchors (easier to remember)

– Define reference points locations anchor ponts
local TOP_REF = 0
local BOTTOM_REF = 1
local LEFT_REF = 0
local RIGHT_REF = 1
local CENTER_REF = 0.5