This project is read-only.

Collision added twice

Nov 18, 2012 at 7:48 AM

It appears to me that since the collision are added on a sprite to sprite basis. All collisions are being registered twice. Meaning

spriteA collides with spriteB <-- 1st occurence

spriteB collides with spriteA <-- 2nd occurence

Is this intended? When I remove a PhysicsSprite from the PhysicsCanvas using the collision delegate, the second occurence will obviously getting a null exception because the sprite was removed in the previous collision. Any suggestions?

- Winston

Nov 18, 2012 at 2:08 PM

Hi Winston,

Since both events are raised (spriteA -> spriteB and spriteB -> spriteA), why not just check for a single combination, like

if (sprite1==sprBall && sprite2 == sprWall)

... and not worry about the second occurrence? Let me know if this doesn't make sense or solve the issue.

Nov 19, 2012 at 4:52 AM

A combination of only checking the first occurrence and moving PhysicsCanvas.DeletePhysicsObject() to PhysicsCanvas.TimerLoop delegate fixed it.