hi guys,
I want to create N number of rectangles on the fly to use as sensors. So that each rectangle listens to collisions happening only inside them.
My question is how to add a collision listener that is independent for each rectangle created?
I tried adding Event Listeners to the rectangle, but I can’t seem to get it right as passing the index to the function is not possible.
many thanks. 
[code]
rectangle ={}
rectIndex = #rectangle +1
rectangle[rectIndex]=display.newRect( 0, 0, 10,10 )
physics.addBody( rrectangle[rectIndex], “static”,{ isSensor = true }
rectangle[rectIndex]:addEventListener(“collision”,rectangle[rectIndex]) ----this is wrong
function rectangle[rectIndex]:collision(e){ —this is also wrong
print(“collision”)
}
[/code] [import]uid: 74667 topic_id: 35714 reply_id: 335714[/import]