Attach one object to another

Hi,
Currently I am building a game where the user can control a stick figure by moving him left and right. He holds a rock in his hand and can drop it when a drop button is pressed. Seconds afterwards, another rock is spawned in and I want it to be attached to the stick figure, as the figure is often moving (via a transition) and the rock needs to keep up with the stick figure. Thanks,

-David [import]uid: 10942 topic_id: 4734 reply_id: 304734[/import]

When going through the API I was surprised that you can’t seem to attach graphics together in a hierarchy. Perhaps I just missed it, but I didn’t see anything along the lines of addChild() from ActionScript.

Instead, what you should do is create a group and insert the stick figure in that group, then move the group and not the stick figure. Now whenever you have another object that should move with the stick figure you can add that object to the group. [import]uid: 12108 topic_id: 4734 reply_id: 15088[/import]

Thanks! I seemed to be having problems removing the object from the group though, without deleting it. I did finally manage to accomplish to task by setting timers to keep updating the position of the rock until it is dropped.

I guess that leaves me with one last question… I’ve set up a collision detection between two objects and I was wondering how I can access both objects within the collision and remove them both. IE: two pucks hit each other and the both are removed. I need to access them using the event variable I believe, but I’m not sure how to remove them using that variable. Thanks [import]uid: 10942 topic_id: 4734 reply_id: 15094[/import]

I don’t know if you found your answer yet but this is what you want.

You need to do research on the Collision event, not pre or post, just plain collision. From here you can access the events from event.object1 and event.object2

[code]
local function onPartsCollision(event)
–add your conditionals
event.object1:removeSelf()
event.object2:removeSelf()

end
[/code] [import]uid: 7197 topic_id: 4734 reply_id: 15628[/import]