So guys i’m trying to make the crate drop only when the crate is tapped, my code was working but after i added a new object to scene the crate is not falling anymore, this is my code.
local function crateTapped( event ) if (event.target.gravityScale == 0) then event.target.gravityScale = 1 print( "Tapped" ) end end -- make a crate (off-screen), position it, and rotate slightly
local crate = display.newImageRect( "crate.png", 45, 45 ) crate.x, crate.y = 60, 0 crate.rotation = 15 crate:addEventListener( "tap", crateTapped ) -- add physics to the crate physics.addBody( crate, { density=1.0, friction=0.3, bounce=0.3 } ) crate.gravityScale = 0
The Tapped gets printed, but the crate does not “fall”