How to move an object with another object

Let’s say if an object was moving, how is it possible to have another object move with a specific object moving in any direction. For example: if I were to show a clothing hanger move from one side to another side, how can the separate clothing object move with the clothes hanger. Any help would be appreciated. I have spent 4 hours today trying to figure this out before I made this post :frowning: [import]uid: 69494 topic_id: 34432 reply_id: 334432[/import]

There are multiple ways to accomplish this, really.

  1. Create a display.newGroup, put all objects you want to move together in the group. Move the group. You should be able to put a touch handler on a group.

  2. In your move code for Object A where you say objecta.x = objecta.x + 1 (or however you are moving it), also move objects B, C and D at the same time, the same distance as you’re moving Object A.

  3. Set up a Runtime “enterFrame” listener that moves B, C and D to where A is (plus whatever distance away from A, the other objects need to be). [import]uid: 199310 topic_id: 34432 reply_id: 136844[/import]

Thanks Rob! It works perfectly! I could’ve sworn I did something like this months ago but I completely forgot because I wasn’t worried about it until I just figured out a good idea for a level :confused: [import]uid: 69494 topic_id: 34432 reply_id: 137181[/import]

Actually, one more question. What if a giant circle was rotating (I gave it a rotation speed so it stands in the middle of the screen and rotates). How can I place the object to move with the rotating circle while placed at the edge of any part of the circle? Whenever I place an object anywhere on the circle, it just stands there and when I try to rotate it with the circle, it stands in one place rotating itself. [import]uid: 69494 topic_id: 34432 reply_id: 137184[/import]

There are multiple ways to accomplish this, really.

  1. Create a display.newGroup, put all objects you want to move together in the group. Move the group. You should be able to put a touch handler on a group.

  2. In your move code for Object A where you say objecta.x = objecta.x + 1 (or however you are moving it), also move objects B, C and D at the same time, the same distance as you’re moving Object A.

  3. Set up a Runtime “enterFrame” listener that moves B, C and D to where A is (plus whatever distance away from A, the other objects need to be). [import]uid: 199310 topic_id: 34432 reply_id: 136844[/import]

I think you may have crossed into the need for Physics and some time of joint making the spinner a wheel of some sort.
[import]uid: 199310 topic_id: 34432 reply_id: 137258[/import]

Thanks Rob! It works perfectly! I could’ve sworn I did something like this months ago but I completely forgot because I wasn’t worried about it until I just figured out a good idea for a level :confused: [import]uid: 69494 topic_id: 34432 reply_id: 137181[/import]

Actually, one more question. What if a giant circle was rotating (I gave it a rotation speed so it stands in the middle of the screen and rotates). How can I place the object to move with the rotating circle while placed at the edge of any part of the circle? Whenever I place an object anywhere on the circle, it just stands there and when I try to rotate it with the circle, it stands in one place rotating itself. [import]uid: 69494 topic_id: 34432 reply_id: 137184[/import]

I think you may have crossed into the need for Physics and some time of joint making the spinner a wheel of some sort.
[import]uid: 199310 topic_id: 34432 reply_id: 137258[/import]