Ghosts vs Monsters help, launching ghost

Hi,

I am learning with the Ghosts Vs Monsters code,

I’ve noticed a small bug in it,

If you repeatedly tap the ghost quickly (when you are due to launch it) you launch it multiple times (you can hear the launch sound effect playing multiple times).

Please can anyone tell me how to limit this so it can only be pressed once?

Thank you [import]uid: 125592 topic_id: 23921 reply_id: 323921[/import]

without looking at the code
you could create a table attribute

blah.isGhostLaunched = false

set it to true on your first tap

then the logic in the tap event handler would be something like…
[lua]if blah.isGhostLaunched == false then
blah.isGhostLaunched = true

if event.phase == “ended” then
– do the ghost launch stuff


end
end[/lua]

the test against isGhostLaunched will trap any extra taps

remember to set blah.isGhostLaunched back to false when the ghost is finished doing its thing. otherwise you’ll never be able to launch another ghost…
[import]uid: 118333 topic_id: 23921 reply_id: 96488[/import]

Thank you for taking the time to reply - it works perfectly!

[import]uid: 125592 topic_id: 23921 reply_id: 96692[/import]