I’ve made a simple game using the “flashlight” sample from Corona simulators library of samples.
I wanted to add a foreground and a backgrounds, so I made a simple display.newGroup() to make things easier, and made the mask, well mask, the entire group with image:setMask( mask ).
But now when I want to leave the scene, my flashlight mask, mask through the new scene. It obviously didn’t get removed.
I’ve tried every trick I could find to removing the mask and the group, but nothing seems to work. what am I doing wrong here?
relevant code:
--group before enterscene, so my button function won't complain about image being nil local image = display.newGroup() function scene:enterScene( event ) local group = self.view display.setStatusBar( display.HiddenStatusBar ) local centerX = display.contentCenterX local centerY = display.contentCenterY --Masking group local image = display.newGroup() -- background image local map = display.newImageRect( image, "img/background.png", display.contentWidth, display.contentHeight ) -- game objective image local map2 = display.newImageRect( image, "img/linx.png", 595, 451 ) map2.x = 340 map2.y = 300 image:translate( centerX, centerY ) local mask = graphics.newMask( "img/light\_cone.png" ) image:setMask( mask ) image.maskScaleX = 0.9 image.maskScaleY = 0.9 end function scene:exitScene( event ) local group = self.view image:setMask( nil ) mask = nil image:removeSelf( ) image = nil storyboard.removeScene("scripts.flashlightgame") end