So I am having issues with my collision detection. I am using the Beebegames.lua class.
Here is my code that creates the chopper:
chopper = newObject( {"chopper.png"}, 60, 38, sw, display.contentHeight+40, nil, nil, 1, playerStuff)
chopper.name = "chopper"
physics.addBody( chopper, "kinematic", {density=0.2, friction=0.2, bounce=0.1 })
transition.to( chopper, {delay=2000, time=2000, transition=easing.outExpo, y=yPosition})
local onLocalCollision = function ( self, event)
if ( event.phase == "began" ) and ( event.other.name == "building" ) then
print("Indeed Yes!")
chopper:destroy()
chopper = nil
end
end
chopper.collision = onBuildingCollision
chopper:addEventListener( "collision", chopper)
Here is the code I use to make some sensors to detect the collision
buildingCollision1 = display.newRect( background, 0, 0, 22, 480)
buildingCollision1.alpha = 0
buildingCollision1.name = "building"
physics.addBody( buildingCollision1, { isSensor=true })
buildingCollision2 = display.newRect( background, 298, 0, 22, 480)
buildingCollision2.alpha = 0
buildingCollision2.name = "building"
physics.addBody( buildingCollision2, { isSensor=true })
So basically on the device and simulator it doesn’t detect the collision, anyone see what im doing wrong? Thanks a lot in advance!
-Kyle
Oh and Merry Christmas!! [import]uid: 9968 topic_id: 4695 reply_id: 304695[/import]