It looks like you're new here. If you want to get involved, click one of these buttons!
local bottomBody = world:createBody({type = b2.STATIC_BODY}) local bottomShape = b2.CircleShape.new(480, 670, 220) bottomBody:createFixture{shape = bottomShape, density = 0} bottomBody.name = "bottomBody" function onEnterFrame(event) world:step(1/60, 8, 3) for body,sprite in pairs(actors) do sprite:setPosition(body:getPosition()) sprite:setRotation(body:getAngle() * 180 / math.pi) --if sprite:getY() > 340 then -- THIS WORKS -- if (removeObject) then -- THIS NOT -- world:destroyBody(body) stage:removeChild(sprite) actors[body] = nil removeObject = false end end end local function onBeginContact(event) -- You can get the fixtures and bodies in this contact like: local fixtureA = event.fixtureA local fixtureB = event.fixtureB local bodyA = fixtureA:getBody() local bodyB = fixtureB:getBody() if ((bodyA.name == "bottomBody") and (bodyB.name == "fallingBody") or (bodyA.name == "fallingBody") and (bodyB.name == "bottomBody")) then score = score + 1 scoreText:setText(score) removeObject = true end end |
Comments
event.x and event.y will not work in the onBeginContact(event)
handler.
Regards,
Marc
http://www.giderosmobile.com/forum/discussion/comment/5908#Comment_5908
There is a way to get collision coordinates, check this thread:
http://www.giderosmobile.com/forum/discussion/comment/22493#Comment_22493
But what I would recommend is to set up the sensors, where your body's might land, etc, so everytime you get a collision with your hidden sensor, you know body should be removed
message a lot. I did the following by the way:
Regards,
Marc