collision force help needed

How do I see the force of a collision?

Current code doesn’t work, it produces “nil”.

[lua]local onsqCollision = function( self, event )
print(event.force)
end

local function buildsquare( sx, sy, img, isdrag, isbreak, breakscore )

local sq = display.newImage(img)
sq.x = sx; sq.y = sy
sq.myName = “breakblock” … math.random()
if (isdrag == 1) then
sq:addEventListener(“touch”, gameUI.dragBody)

end
if (isbreak == 1) then
sq.breakvalue = breakscore
sq.collision = onsqCollision
sq:addEventListener( “collision”, sq)

end
physics.addBody(sq)

end

buildsquare( 200, 200, “crate.png”, 1, 1, 1000)
buildsquare( 100, 200, “crate.png”, 1, 1, 1000)[/lua]

[import]uid: 21962 topic_id: 5986 reply_id: 305986[/import]

The problem is that force is only sent in the postCollision event.

Check out the CollisionDetection sample project.

[code]
local function onLocalPostCollision( self, event )
– This new event type fires only after a collision has been completely resolved. You can use
– this to obtain the calculated forces from the collision. For example, you might want to
– destroy objects on collision, but only if the collision force is greater than some amount.

if ( event.force > 5.0 ) then
print( "postCollision force: " … event.force … ", friction: " … event.friction )
end

end
crate1.postCollision = onLocalPostCollision
crate1:addEventListener( “postCollision”, crate1 )
[/code] [import]uid: 37094 topic_id: 5986 reply_id: 22305[/import]