I can only get the docs example of display.capture to work. Any changes and it breaks - does not return a captured display object. I am trying to populate a group with simple objects and duplicate it.
In the code below only the last function works…
I’m using the iPhone X skin with:
Copyright © 2009-2018 C o r o n a L a b s I n c .
Jan 27 08:48:30.774: Version: 3.0.0
Jan 27 08:48:30.774: Build: 2018.3213
Jan 27 08:48:30.803: Platform: iPhone / x86_64 / 10.12.6 / Intel® Iris™ Graphics 550 / 2.1 INTEL-10.25.17 / 2018.3213 / en-GB | GB | en_GB | en
3.3Ghz i7 with 16 Gb…
local function testGenerateShadow() local group = display.newGroup() group.x, group.y = 400, 400 local a = display.newCircle( group, 0, 0, 100 ) a.fill = {0,1,0} local b = display.newRect( group, 0, 0, 300, 25 ) b.fill = {1,0,0} timer.performWithDelay( 1000, function() local cap = display.capture( group ) group:removeSelf() cap.x, cap.y = 200, 200 print("done") end ) end --testGenerateShadow() local function testCapture() local a = display.newRect( 0, 0, 100, 150 ) a.fill = {1,0,0} local b = display.newRect( 0, 0, 200, 100 ) b.fill = {0,0,1} local g = display.newGroup() g:insert( a ) g:insert( b ) g.x, g.y = 200, 200 local function captureWithDelay() local capture = display.capture( g ) g:removeSelf() capture.x, capture.y = 200, 300 end timer.performWithDelay( 1000, captureWithDelay ) end testCapture() local function captureTest() -- https://docs.coronalabs.com/api/library/display/capture.html#example local myObject1 = display.newRect( 50, 50, 100, 150 ) -- Create a rectangle object local myObject2 = display.newCircle( 100, 300, 50 ) -- Create a circle object myObject1.fill = {1,0,0} myObject2.fill = {1,0,1} local group = display.newGroup() group:insert( myObject1 ) group:insert( myObject2 ) local function captureWithDelay() -- Capture the entire group as a new display object local combined = display.capture( group ) -- Position the new display object combined.x, combined.y = 300, 300 -- Remove it group:removeSelf() combined = nil end timer.performWithDelay( 1000, captureWithDelay ) end --captureTest()