For saving a display group, you have to:
- First create a
display group.
- Then
add the screen objects to that group.
Return the display group
- Use
display.save to save the entire group displayed.
I am giving a sample here:
-- creating the display group --
local stageGroup = display.newGroup()
-- creating display objects and adding it to the group --
local bg = display.newRect(0,0,_w,_h)
bg.x = 160
bg.y = 240
bg:setFillColor(150)
localGroup:insert(bg)
local rect = display.newRect(0,0,50,50)
rect.x = 30+math.random(260)
rect.y = 30+math.random(420)
localGroup:insert(rect)
-- Then do as follows --
local function takePhoto()
-- take screen shot to baseDirectory --
local baseDir = system.DocumentsDirectory
display.save( stageGroup, "myScreenshot.jpg", baseDir )
end
rect:addEventListener("tap",takePhoto)
Note: Make sure that you have added the objects to be appear on the screenshot to the stageGroup.
Keep Coding............. :)