If the overlay has been created without any content it is fully transparent. To have any visible color (object) you must have set up these anywhere in your code. So, the given snippets aren’t your real code?
Delete
screenCap:removeSelf()
from function and move to scene:hide(), or your screenshot gets deleted right before the overlay comes to screen.
Following is the modified code of the sample “Composer” from Corona SDK examples. Copy the folder Composer to a new place and add/replace the attached files or check the code below to get an idea of it.
[spoiler]
overlay.lua
local composer = require( "composer" ) local scene = composer.newScene() local res, screenCap function scene:create( event ) local sceneGroup = self.view screenCap = event.params.sampleVar sceneGroup:insert( screenCap ) end print( "\n1: create event") function scene:show( event ) local phase = event.phase if "did" == phase then print( "overlay: show event, phase did" ) --local image = display.newImage() end end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase local parent = event.parent -- Reference to the parent scene object if ( phase == "will" ) then screenCap:removeSelf() end end local function res(event) if event.numTap==1 then print("tapped") -- By some method such as a "resume" button, hide the overlay composer.hideOverlay( "fade", 1000 ) end end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) Runtime:addEventListener("tap", res) scene:addEventListener( "hide", scene ) return scene
[/spoiler][spoiler]
scene1.lua
--------------------------------------------------------------------------------- -- -- scene1.lua -- --------------------------------------------------------------------------------- local composer = require( "composer" ) local scene = composer.newScene() --------------------------------------------------------------------------------- -- BEGINNING OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- local image, text1, text2, text3, memTimer -- Touch event listener for background image local function onSceneTouch( self, event ) if event.phase == "began" then composer.gotoScene( "scene2", "slideLeft", 800 ) return true end end -- Called when the scene's view does not exist: function scene:create( event ) local sceneGroup = self.view image = display.newImage( "bg.jpg" ) image.x = display.contentCenterX image.y = display.contentCenterY sceneGroup:insert( image ) image.touch = onSceneTouch text1 = display.newText( "Scene 1", 0, 0, native.systemFontBold, 24 ) text1:setFillColor( 255 ) text1.x, text1.y = display.contentWidth \* 0.5, 50 sceneGroup:insert( text1 ) text2 = display.newText( "MemUsage: ", 0, 0, native.systemFont, 16 ) text2:setFillColor( 255 ) text2.x, text2.y = display.contentWidth \* 0.5, display.contentHeight \* 0.5 sceneGroup:insert( text2 ) text3 = display.newText( "Touch to continue.", 0, 0, native.systemFontBold, 18 ) text3:setFillColor( 255 ); text3.isVisible = false text3.x, text3.y = display.contentWidth \* 0.5, display.contentHeight - 100 sceneGroup:insert( text3 ) print( "\n1: create event") end function scene:show( event ) local phase = event.phase if "did" == phase then print( "1: show event, phase did" ) -- remove previous scene's view composer.removeScene( "scene4" ) local screenCap = display.captureScreen( ) screenCap.rotation=180 screenCap:setFillColor(1,1,0,0.8) -- tint the screenshot yellow screenCap.x = display.contentCenterX screenCap.y = display.contentCenterY local optionsT = { isModal = false, effect = "fade", time = 1000, params = { sampleVar = screenCap } } composer.showOverlay( "overlay", optionsT ) -- Update Lua memory text display local showMem = function() image:addEventListener( "touch", image ) text3.isVisible = true text2.text = text2.text .. string.format("%.2g", collectgarbage("count")/1000) .. "MB" text2.x = display.contentWidth \* 0.5 end memTimer = timer.performWithDelay( 1000, showMem, 1 ) end end function scene:hide( event ) local phase = event.phase if "will" == phase then print( "1: hide event, phase will" ) -- remove touch listener for image image:removeEventListener( "touch", image ) -- cancel timer timer.cancel( memTimer ); memTimer = nil; -- reset label text text2.text = "MemUsage: " end end function scene:destroy( event ) print( "((destroying scene 1's view))" ) end --------------------------------------------------------------------------------- -- Listener setup scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) --------------------------------------------------------------------------------- return scene
[/spoiler]