how to bind opjects together no matter what

I need some help I need to bind together several objects. For example I have 5 objects like this

local crate1 = display.newImage("crate.png")  
 -- crate1.x = math.random(0, 310)  
 crate1.x = 30  
 crate1.y = 45  
 -- crate1.rotation = math.random(0, 360)  
 physics.addBody(crate1, {density = 2.0, friction = 1.5, bounce=0.01})  
 crate1.myName = "crate"  
  
 local crate2 = display.newImage("crate.png")  
 -- crate1.x = math.random(0, 310)  
 crate2.x = 90  
 crate2.y = 45  
 -- crate1.rotation = math.random(0, 360)  
 physics.addBody(crate2, {density = 2.0, friction = 1.5, bounce=0.01})  
 crate2.myName = "crate"  
  
 local crate3 = display.newImage("crate.png")  
 -- crate1.x = math.random(0, 310)  
 crate3.x = 150  
 crate3.y = 45  
 -- crate1.rotation = math.random(0, 360)  
 physics.addBody(crate3, {density = 2.0, friction = 1.5, bounce=0.01})  
 crate3.myName = "crate"  
  
 local crate4 = display.newImage("crate.png")  
 -- crate1.x = math.random(0, 310)  
 crate4.x = 210  
 crate4.y = 45  
 -- crate1.rotation = math.random(0, 360)  
 physics.addBody(crate4, {density = 2.0, friction = 1.5, bounce=0.01})  
 crate4.myName = "crate"  
  
 local crate5 = display.newImage("crate.png")  
 -- crate1.x = math.random(0, 310)  
 crate5.x = 270  
 crate5.y = 45  
 -- crate1.rotation = math.random(0, 360)  
 physics.addBody(crate5, {density = 2.0, friction = 1.5, bounce=0.01})  
 crate5.myName = "crate"  

I While the objects are falling downward from the top of the screen or wherever the objects are spawned from they must stay together. For example of another object is crate 3 for example the other crates (1, 2, 4, and 5) must stay together. Also I have a six object called crate6. When crate6 touches any of the crates, crates 1-5 need to be removed from the screen. Can some post a comment here and at e-mail timbojill@gmail.com or PM me through the website. [import]uid: 23642 topic_id: 36590 reply_id: 336590[/import]

It’s not entirely clear from your description what you want to do, but I think you want to have certain objects falling and attaching to each other when they touch. I think you want another object to destroy those objects when it touches them.

To attach objects when they touch you will need to listen for collisions and then weld them with a joint:
http://docs.coronalabs.com/api/event/collision/index.html
http://docs.coronalabs.com/api/type/Joint/index.html

To detect when a destroyer touches the blocks, you’ll still need to listen for collisions, but check which type of block (crate) has been involved in the collision.

Just be aware that when physics objects are removed using removeSelf() although their joints are automatically destroyed, if you have kept a reference to the joint when you called physics.newJoint() you will need to set that reference to nil when you call removeSelf() [import]uid: 8271 topic_id: 36590 reply_id: 144901[/import]

It’s not entirely clear from your description what you want to do, but I think you want to have certain objects falling and attaching to each other when they touch. I think you want another object to destroy those objects when it touches them.

To attach objects when they touch you will need to listen for collisions and then weld them with a joint:
http://docs.coronalabs.com/api/event/collision/index.html
http://docs.coronalabs.com/api/type/Joint/index.html

To detect when a destroyer touches the blocks, you’ll still need to listen for collisions, but check which type of block (crate) has been involved in the collision.

Just be aware that when physics objects are removed using removeSelf() although their joints are automatically destroyed, if you have kept a reference to the joint when you called physics.newJoint() you will need to set that reference to nil when you call removeSelf() [import]uid: 8271 topic_id: 36590 reply_id: 144901[/import]

It’s not entirely clear from your description what you want to do, but I think you want to have certain objects falling and attaching to each other when they touch. I think you want another object to destroy those objects when it touches them.

To attach objects when they touch you will need to listen for collisions and then weld them with a joint:
http://docs.coronalabs.com/api/event/collision/index.html
http://docs.coronalabs.com/api/type/Joint/index.html

To detect when a destroyer touches the blocks, you’ll still need to listen for collisions, but check which type of block (crate) has been involved in the collision.

Just be aware that when physics objects are removed using removeSelf() although their joints are automatically destroyed, if you have kept a reference to the joint when you called physics.newJoint() you will need to set that reference to nil when you call removeSelf() [import]uid: 8271 topic_id: 36590 reply_id: 144901[/import]

It’s not entirely clear from your description what you want to do, but I think you want to have certain objects falling and attaching to each other when they touch. I think you want another object to destroy those objects when it touches them.

To attach objects when they touch you will need to listen for collisions and then weld them with a joint:
http://docs.coronalabs.com/api/event/collision/index.html
http://docs.coronalabs.com/api/type/Joint/index.html

To detect when a destroyer touches the blocks, you’ll still need to listen for collisions, but check which type of block (crate) has been involved in the collision.

Just be aware that when physics objects are removed using removeSelf() although their joints are automatically destroyed, if you have kept a reference to the joint when you called physics.newJoint() you will need to set that reference to nil when you call removeSelf() [import]uid: 8271 topic_id: 36590 reply_id: 144901[/import]