Snapshot and displayobjects pooling

What happen when I insert an object into a snapshot A and the frame after (once the render of snapshot A is done), I insert the object into a snapshot B? My assumption are that I will have 2 snapshots with the same visual aspect.

I trying to use object pooling with snapshot to display a tiled background but it’s not working, some times my snapshots are empty. It works when i don’t pool the objects.

So here is my question, can I insert an object successively into different snapshots?

An object can not be in two groups at once. (Unless it’s in a group within another group but it’s not the case)

That said, you can insert the same image in 2 snapshots. Using a small timer:

local snap1 = display.newSnapshot( 100, 100 ) snap1:translate( 160, 100 ) local tmp1 = display.newRect( snap1.group, 0, 0, 100, 100 ) tmp1:setFillColor( 1, 0, 1 ) local snap2 = display.newSnapshot( 100, 100 ) snap2:translate( 160, 300 ) local tmp2 = display.newRect( snap2.group, 0, 0, 100, 100 ) tmp2:setFillColor( 0, 1, 1 ) local myImage = display.newImageRect( "img.png", 80, 80 ) snap1.group:insert( myImage ) timer.performWithDelay( 1, function() snap2.group:insert( myImage ) snap2:invalidate( ) end, 1 )

However once this is done the image will be in the snap2(As I said an image can not be in multiple groups).

This means that if you after the code I put I would do something like:

snap1:invalidate( )

The snap1 is updated and you will no longer see the image in that snapshot.

Finally you can look at the documentation for more information:

https://docs.coronalabs.com/api/type/SnapshotObject/index.html

https://docs.coronalabs.com/guide/graphics/snapshot.html

I hope you help

An object can not be in two groups at once. (Unless it’s in a group within another group but it’s not the case)

That said, you can insert the same image in 2 snapshots. Using a small timer:

local snap1 = display.newSnapshot( 100, 100 ) snap1:translate( 160, 100 ) local tmp1 = display.newRect( snap1.group, 0, 0, 100, 100 ) tmp1:setFillColor( 1, 0, 1 ) local snap2 = display.newSnapshot( 100, 100 ) snap2:translate( 160, 300 ) local tmp2 = display.newRect( snap2.group, 0, 0, 100, 100 ) tmp2:setFillColor( 0, 1, 1 ) local myImage = display.newImageRect( "img.png", 80, 80 ) snap1.group:insert( myImage ) timer.performWithDelay( 1, function() snap2.group:insert( myImage ) snap2:invalidate( ) end, 1 )

However once this is done the image will be in the snap2(As I said an image can not be in multiple groups).

This means that if you after the code I put I would do something like:

snap1:invalidate( )

The snap1 is updated and you will no longer see the image in that snapshot.

Finally you can look at the documentation for more information:

https://docs.coronalabs.com/api/type/SnapshotObject/index.html

https://docs.coronalabs.com/guide/graphics/snapshot.html

I hope you help