isSensor not working with group objects.

Hi, 

I have display new image1 and  image2.

I’m getting collision event  if i set isSensor=true for image1.

but if I group both image1, image2 and add physics to “group” with isSensor  true then I’m not getting the collision events.

Code snippet:

sens = display.newImage(sensor, 30, 30)

physics.addBody( sens , “static”, {isSensor = true} ) – senor at 30,30

obj1 = display.newImage(image1, 10,20)

obj2 = display.newImage(image2, 10,40)

group:insert(obj1)

group:insert(obj2)

physics.addBody( group ,{isSensor = true} )

transition.to(group, x=50, time=3000)  – both image1 & 2 are grouped and move to x=50 for collision.

Runtime:addEventListener( “collision”, onCollision )

– No Event :-( 

Note: If I add physics to image1 only and move it to x=50 then I’m getting the collision event. 

Sudheer 

Some things to remember about physics, collisions, and display groups, from the setDrawMode API page:

Gotchas

When working with Corona display groups and Box2D, it’s important to remember that Box2D expects all physics objects to share a  global coordinate system. Both grouped and ungrouped display objects will work well since they will share the internal coordinates of that group. However, unexpected results will occur if physical objects are added to different display groups and those groups are moved, scaled, or rotated independently of each other. As a general rule, do  not  alter the position, scale, or rotation of display groups that contain physics objects.

In addition, using transition.to instead of a physics API to move objects has it’s own complications. Here’s a link to a Corona Geek video talking about the pros and cons of each.

Some things to remember about physics, collisions, and display groups, from the setDrawMode API page:

Gotchas

When working with Corona display groups and Box2D, it’s important to remember that Box2D expects all physics objects to share a  global coordinate system. Both grouped and ungrouped display objects will work well since they will share the internal coordinates of that group. However, unexpected results will occur if physical objects are added to different display groups and those groups are moved, scaled, or rotated independently of each other. As a general rule, do  not  alter the position, scale, or rotation of display groups that contain physics objects.

In addition, using transition.to instead of a physics API to move objects has it’s own complications. Here’s a link to a Corona Geek video talking about the pros and cons of each.