Hello! Before the function:scene:createScene (event) I added a function that removes an object when it is touched.
function l82\_2( self, event ) if event.phase == "began" then clickover2 = audio.play( click2 ) aa=1 l82:removeSelf( ) storyboard.gotoScene( "scene10", "crossFade", 75 ) end return true end function scene:createScene( event ) local screenGroup = self.view l82 = display.newImage("level4\_82.png") l82.x = display.contentWidth / 1.9 l82.y = display.contentHeight / 1.9 screenGroup:insert( l82 ) l82.touch = l82\_2 l82:addEventListener( "touch", l82 ) end
After the image is pressed it is removed and storyboard goes to next scene; however if I try to come back from a scene to this scene if I press again the image I get the following error:
attempt to call method ‘removeSelf’ <a nil value>
Thank you.