Any way to reset the X/Y of an object after rotate?

I am using the anchorX/Y set to 0 and I rotate an object. Is there a way to reset the x/y of an object to the top left once its rotated? By other alternative is to have 4 images of an object and reset the image with another showing it rotated since I am only changing it 90 degrees at a time.

Warren

can you post some code and explain it? thanks

Sounds like you want to rotate about an anchor point.

Try running this example in each of the 5 modes it supports to see what I mean:

local function test( num ) local anchors = {} anchors[1] = { 0.5, 0.5 } anchors[2] = { 0, 0 } anchors[3] = { 0, 1 } anchors[4] = { 1, 0 } anchors[5] = { 1, 1 } local tmp = display.newRect( display.contentCenterX, display.contentCenterY, 200, 50) tmp.anchorX = anchors[num][1] tmp.anchorY = anchors[num][2] local anchorMark = display.newCircle( tmp.x, tmp.y, 10 ) anchorMark:setFillColor(1,0,0) transition.to( tmp, { delay = 1000, rotation = 360, time = 5000 } ) end

test (2)

What I want to do is after I rotate the object I wish I could reset the anchor point to be at the top left of the object. I am moving a tile in a dominoes game and there are times I need to rotate the tile 180 to match the values for tiles to place. I know after I rotate it I just move the tile over to compensate. But I would prefer to just reset the x/y and adjust the placement from there.

Can you change the anchor point of an object after it is rotated? All of my objects uses an anchorX/Y or 0.

Thanks,

Warren

can you post some code and explain it? thanks

Sounds like you want to rotate about an anchor point.

Try running this example in each of the 5 modes it supports to see what I mean:

local function test( num ) local anchors = {} anchors[1] = { 0.5, 0.5 } anchors[2] = { 0, 0 } anchors[3] = { 0, 1 } anchors[4] = { 1, 0 } anchors[5] = { 1, 1 } local tmp = display.newRect( display.contentCenterX, display.contentCenterY, 200, 50) tmp.anchorX = anchors[num][1] tmp.anchorY = anchors[num][2] local anchorMark = display.newCircle( tmp.x, tmp.y, 10 ) anchorMark:setFillColor(1,0,0) transition.to( tmp, { delay = 1000, rotation = 360, time = 5000 } ) end

test (2)

What I want to do is after I rotate the object I wish I could reset the anchor point to be at the top left of the object. I am moving a tile in a dominoes game and there are times I need to rotate the tile 180 to match the values for tiles to place. I know after I rotate it I just move the tile over to compensate. But I would prefer to just reset the x/y and adjust the placement from there.

Can you change the anchor point of an object after it is rotated? All of my objects uses an anchorX/Y or 0.

Thanks,

Warren