Move objects in a Snapshot

Hello everyone

In my project I have a snapshot with inside other objects. The snap is often rotated and flipped(ex. snap.xScale - 1).

I would like to move objects within it as if their x and y are “normal” and not “confused” by the many changes the snap.

Is there a way to do it? Otherwise even move an object (in the snap) a little to the right becomes very complicated (Ex. obj.x obj.x = + 10 as certainly not the result that we imagine)

I hope for a solution thanks

The easy way to map a screen coordinate to a location within a display group is to use :contentToLocal(), and it’s cousin :localToContent(). I don’t know if this will work quite the way you’re intending with a snapshot being flipped, but why not just NOT flip it via scaling? If you’re moving everything within it as normal, by bother flipping it?

With a localToContent I get the actual location of an object. To me, however, it is used to move an object by following the actual positions regardless of the snap variations.

I attach the code and a image to explain better.

code:

local snap = display.newSnapshot( 300, 300 ) snap:translate( 160, 250 ) local bg = display.newRect(0, 0, 300, 300) snap.group:insert(bg) local rect = display.newRect( 0, 0, 50, 50 ) rect:setFillColor( 1, 0, 0 ) snap.group:insert(rect) transition.to(snap, {time = 2000, xScale = -1}) local newX = rect.x + 100 transition.to(rect, {time = 2000, x = newX }) local function updates() snap:invalidate( ) end Runtime:addEventListener( "enterFrame", updates )

No solution?

The easy way to map a screen coordinate to a location within a display group is to use :contentToLocal(), and it’s cousin :localToContent(). I don’t know if this will work quite the way you’re intending with a snapshot being flipped, but why not just NOT flip it via scaling? If you’re moving everything within it as normal, by bother flipping it?

With a localToContent I get the actual location of an object. To me, however, it is used to move an object by following the actual positions regardless of the snap variations.

I attach the code and a image to explain better.

code:

local snap = display.newSnapshot( 300, 300 ) snap:translate( 160, 250 ) local bg = display.newRect(0, 0, 300, 300) snap.group:insert(bg) local rect = display.newRect( 0, 0, 50, 50 ) rect:setFillColor( 1, 0, 0 ) snap.group:insert(rect) transition.to(snap, {time = 2000, xScale = -1}) local newX = rect.x + 100 transition.to(rect, {time = 2000, x = newX }) local function updates() snap:invalidate( ) end Runtime:addEventListener( "enterFrame", updates )

No solution?