Dragonfly Q&A

Saucer Shoot Tutorial has Multiple Collisions

0 like 0 dislike

I'm testing the game of Saucer Shoot, and it seems as though collision events sometimes fire multiple times in one step. This means that when I shoot a Saucer, sometimes it will generate two new Saucers instead of just one. Is that expected behavior?

asked Jun 23, 2014 in Tutorial by Questioner

1 Answer

0 like 0 dislike

Yes, that could happen - the behaviour you mention is subtle. Every collision generates an event that is sent to both objects. When a bullet moves and hits a saucer, the hit() method will mark the saucer for deletion, and generate a new saucer. If the saucer also moves that same step (it wasn't actually deleted yet) it will move and hit the bullet, again generating an event for both objects where hit() again generates a new saucer.

It doesn't really matter for gameplay (only 10 points are added either way) so it remains.


answered Jun 23, 2014 by claypool
More information about Dragonfly can be found on the Dragonfly Home Page.