Managing Groups of Objects

Get help using Construct 2

Post » Wed Apr 03, 2013 5:17 am

Is there a way to "Group" a few objects and treat them as one "Unit"? AND move them as one Unit keeping their relative positions to each other?

I think this is what Containers are designed for, but my problem is I want to DRAG/DROP the "Group" as a whole and maintain each objects position to one another without custom code for each and every object. With the few things I have tried, on DRAG/DROP all the objects in the Container are positioned to the new X/Y, instead of the "primary" objects new position and their position relative to it, so fail.

See attached .capx. You will see as you Drag the Large Green Square the two rects that "belong" to it will follow and re-position, but that is due to a every tick that is not scale-able and when one of those rects overlaps with the rect on the Red square it will accept the placement, otherwise it will throw the Big Green and its rects to a "starting" location.

What I would like to do is make everything generic, so I don't need 8000 lines of code, one-off for if Obj1 is moved, Obj2 is moved, every tick move Obj1 and all its parts etc...

http://dl.dropbox.com/u/8949954/BoxGrouping.capx

Thanks
Brett
B
21
S
7
G
1
Posts: 128
Reputation: 3,076

Post » Wed Apr 03, 2013 7:49 am

Check out the pin behavior, seems to be what you are looking for.

Containers are meant for object sets, that live, die and operate together. So combination of those two should be what yo are looking for :)

To make things more generic and easier to manage, look into placing your things into single object as a separate animation/frames or using families.
B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Wed Apr 03, 2013 4:47 pm

Excellent, thank you. Just want I needed. I have it working and am now working on making the code more generic, making good headway on that too. Thanks again.

Brett
B
21
S
7
G
1
Posts: 128
Reputation: 3,076


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests