I thought snapshots were supposed to render offscreen?

Hi Corona!

I have been playing around with snapshots and looked at your docs at http://docs.coronalabs.com/guide/graphics/snapshot.html.

However, the snapshots don’t seem to be rendering offscreen as stated below:

“Snapshot objects are easily created using Corona’s display.newSnapshot() method. You can add children objects to snapshots by accessing the snapshot’s group. This property is like a normal GroupObject but it does not directly affect the scene. Instead, these objects are rendered to a texture offscreen , and the texture determines what the snapshot renders.”

You have example code on the same page that I tried and it seems to render it all ON SCREEN:

local snapshot = display.newSnapshot( 200, 200 ) math.randomseed( 0 ) -- Add 4 fish images to the screen for i = 1,4 do -- Create a fish local fish = display.newImage( "fish-small-red.png" ) -- Move it to a random position relative to the snapshot's origin fish:translate( math.random( -100, 100 ), math.random( -100, 100 ) ) -- Insert the fish into the snapshot snapshot.group:insert( fish ) end snapshot:translate( display.contentCenterX, display.contentCenterY ) -- Center the snapshot on the screen snapshot:invalidate() -- Invalidate the snapshot transition.to( snapshot, { alpha=0, time=2000 } ) -- Fade the snapshot out

I don’t understand why there is the snapshot:translate(…) line. How can you center the snapshot on the screen if snapshots are not supposed to render to the screen?

If you omit that line of code, the snapshot is still rendered to the screen anyway.

Can somebody explain to me what is going on?

Thanks in advance!

Hi @spacewolf,

I sympathize with the confusion on this, and I know our snapshot guide/docs need improvement and clarification. I intend to put effort toward that soon.

To answer your question, don’t really think about this “offscreen” thing too literally. The snapshot is a display object (presumably onscreen) and you insert into or remove objects from it, then you “invalidate” it to put those changes into effect. What is happening “offscreen” is more of an under-the-hood operation, so don’t consider it like the snapshot is actually residing offscreen or anything like that.

Best regards,

Brent

Ah okay, thanks for the clarification!

Hi @spacewolf,

I sympathize with the confusion on this, and I know our snapshot guide/docs need improvement and clarification. I intend to put effort toward that soon.

To answer your question, don’t really think about this “offscreen” thing too literally. The snapshot is a display object (presumably onscreen) and you insert into or remove objects from it, then you “invalidate” it to put those changes into effect. What is happening “offscreen” is more of an under-the-hood operation, so don’t consider it like the snapshot is actually residing offscreen or anything like that.

Best regards,

Brent

Ah okay, thanks for the clarification!