Hey guys how do I figure out when a object collides with a certain object then call the event lisatner. I am trying to make it so when the player collides with the enmey it will subtract health. But when it collides with the ground it subtracts health to ?
local function enemyattack( event ) if playerhlth\>1 then playerhlth = playerhlth - 1 print("you are being attacked") print("your health is",playerhlth) local urhealth = display.newText(playerhlth,square.x,square.y,25,25) --score/health display urhealth:setFillColor(0,1,0) transition.to(urhealth,{time= 4000,x=0,y=-500}) end end --square is main chareacter square:addEventListener("collision",enemyattack)