Hi there,
I’m making a game with a small boss. My boss has 5hp.
I set a touch event listener to my boss. And I want to reduce my boss’hp by 1 each time the player touches or slides his finger on the boss. But the hp of my boss goes down to 0. Immediately since the touch event triggers the code multiple times.
[lua]local function bossHit(event)
if ( event.phase == “began” or event.phase == “moved” or event.phase == “ended” ) then
bossHP = bossHP -1
end
end
boss:addEventListener( “touch”, bossHit )[/lua]
Is there a way the counter just go down by 1 each time the event it’s trigger?
Thanks a lot for your help.