The upgrade of Box2D to version 2.2.1 has broken pre-collisions. The best way to illustrate this is with the sample code directly from the isSensor documentation:
[code]local physics = require(“physics”)
physics.start()
display.setStatusBar( display.HiddenStatusBar )
local platform1 = display.newRect( 20, 200, 280, 15 )
platform1.myName = “platform1”
physics.addBody(platform1, “static”)
local platform2 = display.newRect( 20, 320, 280, 15 )
platform2.myName = “platform2”
physics.addBody(platform2, “static”)
local box = display.newRect( 20, 20, 50, 50 )
box:setFillColor(255,255,0,255)
box.myName = “box”
physics.addBody(box)
local function onLocalPreCollision( self, event )
– Let box pass through platform 1
local platform = event.other
if platform.myName == “platform1” then
platform.isSensor = true
end
end
box.preCollision = onLocalPreCollision
box:addEventListener( “preCollision”, box )[/code]
The box should fall through the first platform and hit the second, however, it bounces of the first platform and falls through on the second attempt.
As far as I can see, when the block incorrectly collides with the first platform, the collision ‘began’ event is fired before the preCollision event.
Note: I tried to report this via the “Report a bug” link 4 days ago, but I can’t find it in the public bug tracker. [import]uid: 35618 topic_id: 30132 reply_id: 330132[/import]