If you run the following code you will see that local precollision is dispatched after the global collision. Is this intended behaviour as it doesn’t make any sense at all. The whole point of PreCollision should be to happen pre - collision so that you could override the intended behaviour. Please advise if there are some workarounds. Thanks.
output:
onCollision: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
[code]
local physics = require “physics”
physics.start()
local box1 = display.newRect(50, 50, 50, 50)
box1.name = “box1”
physics.addBody(box1, “dynamic”, { density=1.0 } )
local box2 = display.newRect(55, 250, 150, 150)
box2.name = “box2”
physics.addBody(box2, “static”, { density=1.0 } )
box1.preCollision = function(self, event)
print("box1.preCollision, with: " … self.name … ", " … event.other.name)
end
local function onCollision(event)
print("onCollision: " … event.object1.name … ", " … event.object2.name)
end
Runtime:addEventListener( “collision”, onCollision )
box1:addEventListener(“preCollision”, box1)
[/code] [import]uid: 21280 topic_id: 7511 reply_id: 307511[/import]