How do I group several objects so they follow the parent?

Get help using Construct 2

Post » Fri Apr 01, 2016 11:08 am

Hi

Is there a smart way to have several sprites grouped under one, so i can move and rotate and scale the parent and all the sprites under it will follow? Or do i have to use pin behaviour on each one and pin it in the event for every one?

Cheers
B
7
S
1
Posts: 12
Reputation: 799

Post » Fri Apr 01, 2016 11:12 am

You could use this plugin viewtopic.php?t=67642&start=0
or simpler way is to create an instance variable for the child where you store the parent UID, then you could pick the parent by UID = Child.varUID and send them to that dirrection.
I use the MoveTo in all my projects . you cand find it here http://www.scirra.com/forum/c2-plugins- ... 47002.html
B
84
S
21
G
23
Posts: 521
Reputation: 18,789

Post » Fri Apr 01, 2016 6:01 pm

Hi Thanks for the reply. Ive been looking the plugins over and i cant figure out how they are supposed to do what i need.
I need to group or link several sprites to the parent/root sprite. Do when i move/rotate/scale the parent/root sprite all the other sprites will follow in their respective positions to the parent/root sprite.

Those 2 plugins you posted, they can do that? If yes could you explain how?

Thanks a million.
B
7
S
1
Posts: 12
Reputation: 799

Post » Fri Apr 01, 2016 6:20 pm

@Omnigen It depends on what exactly you want them to behave...but you can use Pin behavior. Open C2 and the new project and search for Pin examples. You can have more types of pins: rope style, bar style, glued style
Unfortunately the Pin behavior does not support scalling, but support angle, position
B
84
S
21
G
23
Posts: 521
Reputation: 18,789

Post » Fri Apr 01, 2016 10:37 pm

Yeah i know pin behaviour as i mentioned i my post hehe. But its a pain to all the time pin and unpin a lot of objects. Kinda of why i could use a group i could stick all the sprites into and then move/rotate or scale them all at the same time. :/
B
7
S
1
Posts: 12
Reputation: 799

Post » Sat Apr 02, 2016 12:52 am

Use family to these child sprites and store the main sprite uid in a family instance variable and then use pin behavior in the family. For the scale(width/height) use percentage so whenever you scale the main sprite, you will have to apply the same percentage to the child sprites. This way you keep between them the same initial proportion.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Sat Apr 02, 2016 6:34 pm

Hmm. That sounds like it might work. I will give it a go. :D

Thanks
B
7
S
1
Posts: 12
Reputation: 799


Return to How do I....?

Who is online

Users browsing this forum: John Cutter and 7 guests