Is there a way I can make a button on an overlay of a scene remove an object from the scene?
local widget = require( "widget" ) -- Function to handle button events local function handleButtonEvent( event ) composer.hideOverlay("ifc.drop", options ) if event.phase == "ended" and eggplant.alpha ~= 0 then eggplant.alpha = 0 physics.removeBody(eggplant) end if ( "ended" == event.phase ) then print( "Button was pressed and released" ) end end local removeeggplant = widget.newButton( { width = 80, height = 40, defaultFile = "images/level.png", overFile = "images/level.png", label = "", onEvent = handleButtonEvent } ) -- Center the button removeeggplant.x = 200 removeeggplant.y = 20 -- Change the button's label text removeeggplant:setLabel( "Remove" ) sceneGroup:insert(removeeggplant)
So I have this code above that has a button on an overlay called “drop” that when pushed hides the overlay and removes the eggplant, but because the eggplant is not in the overlay but in the scene it doesn’t work, is there a way I can make the button remove the eggplant from the scene from the overlay?