Collision function not working.

Hey Ho.

For some reason my latest collision object & function are not working.
It’s pretty simple and I did something similar just above it, but this one seems to not come into contact with anything (Or register is has anyway.)

--------------------------------------- Deletion Protocal --------------------------------------  
 -- --  
 ------------------------------------------------------------------------------------------------  
  
 local delSensor = display.newRect(20, 0, 6, 360) -- Create a long bar to act as collision bar.  
 --delSensor.isSensor = true  
 physics.addBody(delSensor, "static", {isSensor = true}) -- Turn it to a sensor, I tried this physics way & above way commenting this line out.  
 ui:insert(delSensor) -- I insert it to the ui group, this will not move from the screen no matter what the game does.  
  
 local function delProtocol(e) -- create my deletion protocal  
 if (e.phase == "ended") then -- if the object leaves the bar  
 --display.remove(e.other)  
 --e.other = nil  
 print("Protocol Initiated:") -- Just print will do for now. (This doesn't register at all.)  
 end  
 end  
 delSensor:addEventListener("collision", delProtocol) -- delSensor gets the listener to use this function when collision occurs.  

I can’t see anything wrong with that, I did something the same for when I collect a coin and that worked.

The things that come to mind:

  • the sensor is in the ui group but the objects are in the ‘game’ group, I tried changing it to game group too, nothing. Also tried colliding another ui object with it, nothing.

  • Can you have multiple of these types of collision for different objects?

I just can’t seem to get the print statement to come up.
Thanks again. =) [import]uid: 91798 topic_id: 29722 reply_id: 329722[/import]

Well you DO have to have anything colliding in the same group.

Now as to why it didn’t fire while it was in the game group, I’m not sure. We probably need to see a little more code.
[import]uid: 19626 topic_id: 29722 reply_id: 119352[/import]