cykod / Quintus

HTML5 Game Engine
http://html5quintus.com
GNU General Public License v2.0
1.41k stars 401 forks source link

Collision detection and destroy() #134

Closed vincentjames501 closed 10 years ago

vincentjames501 commented 10 years ago

I haven't dug into the problem much, but it looks like it's possible for a collision to be detected on an object that has already been destroyed. My collision function now has to check for if(this.isDestroyed()) before processing where I think this logic should go in the collision engine so that a collision listener won't be called on an already destroyed object. If you need any more information let me know!

cykod commented 10 years ago

Since Quintus doesn't do real resolution of collisions (i.e. it does one object at a time) I generally treat one "step" as a unit of time - this means if three objects all collide in the same step, they all have collisions triggered. Pre-checking for isDestroyed in the collision system means that two would collide and destroy themselves, for example, and then the third wouldn't be affected.

Can you give some examples where this behavior leads to undesirable results in your game?