Ok, sorry. I’ll do it step by step.
-
Main Object:
Saving a screenshot with a pre-destined name in the camera roll. (or desktop)
-
What I have:
local capture=display.newRoundedRect( 0,0,50,50,10) --making the screenshot button
capture.alpha=0.5
capture.isHitTestable=true
local function captureToFile(event)
if event.numTaps==2 then -- only on double tap
local time = os.date("\*t")
local hour = time.hour
local minute=time.min
local second=time.sec
local day=time.day
local month=time.month
local year=time.year
local completeTime=(month.."-"..day.."-"..year.."\_@"..hour.."."..minute.."."..second..".jpg") --setting the current time and date as name
capture.alpha=0 --hide the capture button
display.save( display.currentStage, completeTime, system.DocumentsDirectory) --save the image in documents directory with pre-destined name
capture.alpha=1 -- show the capture button
local myImage=display.newImage(completeTime, system.DocumentsDirectory) -- display the saved image, in response to your advice "display the image and then capture the screen"
myImage.x, myImage.y=middleX, middleY
myImage:scale(2,2) -- normal image only fills top corner
end
end
capture:addEventListener( "tap", captureToFile )
- My Minor Question:
How do you remove the image once you’ve called display.captureScreen, as it displays it on the entire screen?
How would I save the name with the file? [import]uid: 147322 topic_id: 27350 reply_id: 111412[/import]