Hello everyone,
I’m building an app which is meant for educational puropses. At some point, the students need to take a picture. When they are done, they can press a button. When the button is pressed, the scene changes. I find myself unable to delete the taken picture. Has anyone got any ideas? Here is my code:
----------------------------------------------------------------------------------------- -- -- scene2.lua -- ----------------------------------------------------------------------------------------- local storyboard = require( "storyboard" ) local widget = require "widget" local scene = storyboard.newScene() local function returnHome() storyboard.gotoScene( "splash", "crossFade", 1000 ) return true end function scene:createScene( event ) local group = self.view local centerX = display.contentCenterX local centerY = display.contentCenterY local \_W = display.contentWidth local \_H = display.contentHeight local isXcodeSimulator = "iPhone Simulator" == system.getInfo("model") if (isXcodeSimulator) then local alert = native.showAlert( "Information", "Camera API not available on iOS Simulator.", { "OK"}) end local bkgd = display.newImage("foto\_but.png") bkgd.x = 117 bkgd.y = 565 local sessionComplete = function(event) local image = event.target print( "Camera ", ( image and "returned an image" ) or "session was cancelled" ) print( "event name: " .. event.name ) print( "target: " .. tostring( image ) ) if image then image.x = 765 image.y = 395 image:scale( 0.4, 0.4 ) local w = image.width local h = image.height print( "w,h = ".. w .."," .. h ) end end local listener = function( event ) if media.hasSource( media.Camera ) then media.capturePhoto( { listener = sessionComplete } ) else native.showAlert("Corona", "Camera not found.") end return true end bkgd:addEventListener( "tap", listener ) local background = display.newImage("workscreen.png") background.x = display.contentWidth/2 background.y = display.contentHeight/2 appicon = widget.newButton{ defaultFile="klaar\_but.png", onRelease = returnHome } appicon.x = 117 appicon.y = 650 group:insert ( background ) group:insert ( appicon ) group:insert ( bkgd ) if image then group:insert ( image ) end end function scene:enterScene( event ) local group = self.view end function scene:exitScene( event ) local group = self.view end function scene:destroyScene( event ) local group = self.view if appicon then appicon:removeSelf() appicon = nil end end scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene
Thanks in advance!