isSensor Collision Problem

Hey Guys,

Looking to see if someone can help me figure out / brainstorm as to why my collision is not firing. Basically I have an object in the middle of the screen and as my “enemies” pass into this object I want to disable the tap event for them. I have the following code which dose not appear to trigger the collision when my enemy passes over the middle object

Middle Object (names of object changed)

local window = display.newImageRect( "images/controlUnit.png", 140, 202 ) window.x = centerX window.y = centerY -5 physics.addBody( window, "static", { isSensor=true } ) window.name = "window" group:insert(window) window:addEventListener("collision", window) function window:collision (event) print( "what is going on" ) if event.phase == "began" then print( "collision detected" ) end end

and my enemy (names changed)

bug[TotalBugs] = display.newSprite( sheet, sequence) bug[TotalBugs]:play() --setup tab listener bug[TotalBugs]:addEventListener( "tap", bugKilled ) --setup where bug will spawn bug[TotalBugs].x = startingX bug[TotalBugs].y = startingY if startingX \>= centerX then bug[TotalBugs]:scale(-1,1) end physics.addBody( bug[TotalBugs], "static", { isSensor=true} ) bug[TotalBugs].name = "enemy" group:insert(bug[TotalBugs]) --move the bugs to the center of the screne --bug[TotalBugs].trans = transition.to(bug[TotalBugs],{ time=2000, x=centerX, y=centerY, onComplete=bugKilled}) bug[TotalBugs].trans = transition.to(bug[TotalBugs], { time=2000, x=centerX, y=centerY, onComplete = function (self) transition.cancel ( self ) transition.to( self, {time=1000, alpha=0, xScale=0.1, yScale=0.1, onComplete = function (self) transition.cancel ( self ) display.remove(self); self = nil; end } ) -- Minus lives as has hit center and then determine if lives = 0 if so call activateGameOver() lives = lives - 1 if lives \<= 0 then --self:removeEventListener( "tap", bugKilled ) --timer.cancel(tmr\_createBug) --print( "livesOver" ) end end; })

unsure as to why the collision is not working. anyone have any ideas?

Looking at this quickly, you have window and bug both created as static.  Static objects cannot collide with other static objects.

Looking at this quickly, you have window and bug both created as static.  Static objects cannot collide with other static objects.