I have been designing a simple space shooter, which involves a ship at the bottom of the screen firing lasers at enemies coming down from above.
With the latest public build 2381 the collisions between the laser and the enemy are only being detected about 1/3 of the time, based on my onCollision event. It was working fine with the earlier public build however.
I’m just wondering if what I am doing is correct, as it was working before… or maybe I was just lucky.
Here is the code for the laser my ship fires:
physics.addBody(laser, "dynamic") laser.gravityScale = 0 laser.isSensor = true -- prevents laser from becoming crooked when coming out of my ship
And for the enemy:
physics.addBody(enemy, "dynamic") enemy.gravityScale = 0 -- don't move with gravity enemy.isSensor = true -- don't bounce on impact with my ship
These physics bodies are all newImageRects. I’ve added a ‘collision’ event listener to the laser and ship, but not to the enemy.
laser:addEventListener( "collision", onCollision )
Is there anything I should do to the above to ensure my collisions are working with the latest public build?