How do containers actually work?

Get help using Construct 2

Post » Fri Nov 23, 2012 2:45 am

How do containers actually work?

What practical uses do they have?

Couldn't you just create a family with said objects and it would behave the same?
B
16
S
6
G
6
Posts: 100
Reputation: 4,840

Post » Fri Nov 23, 2012 4:47 am

I think you could actually consider a family a type of container.

http://en.wikipedia.org/wiki/Container_(abstract_data_type)

Was this relevant to an issue you are trying to work around in your game development? If not, you may want to try the "Open Topic" section.
B
20
S
4
G
2
Posts: 124
Reputation: 2,482

Post » Fri Nov 23, 2012 2:14 pm

Yes. What I'm trying to do, is to find a way to easily group objects and their position. This features' glaring absence is annoying :)
B
16
S
6
G
6
Posts: 100
Reputation: 4,840

Post » Fri Nov 23, 2012 3:36 pm

The best description of containers is currently in the r110.2 release notes. (The manual will be updated at the next stable release.)

Containers and families are different and used for different purposes. Putting objects in a family won't pick the associated instances from other objects in the family - it just allows you to make events that apply to lots of objects at once (e.g. you can make events for "Enemies" rather than for each individual sprite). Containers on the other hand are for making "composite objects", or objects made out of lots of smaller sprites (such as a turret and tank base making a single tank). Once in a container, picking the base also picks the turret, and vice versa.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Fri Nov 23, 2012 3:38 pm

An example would be a huge boss with lots of turrets and body parts - adding these to a container makes your eventing so much cleaner.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Fri Nov 23, 2012 9:31 pm

If every item in your container could be easily translated or rotated in relation, it would be awesome. They're still picked individually though.

So if I were to make a big boss for example with lots of guns. I would make a family out of his body parts so that I could destroy each gun as the player hits it.

Also make the events cleaner than containers because you only have to move the family, not every single body part individually.

What I'm trying to say is, I don't really see what this brings to the table that couldn't be done before.
B
16
S
6
G
6
Posts: 100
Reputation: 4,840

Post » Fri Nov 23, 2012 10:21 pm

That is hell of an awesome feature !
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Fri Nov 23, 2012 10:28 pm

Example with no container
In this capx I have to do the picking manually and store UID values in instance variables to be able to link a "Head" to a "Body".

Example with container
In this capx, no need to store UID values, the contained "Head" is automatically picked. Same goes for "Body" when the "main picked object" is a contained "Head".


For both projects: cursor over the body (colored big square) will modify the "attached" "Head"'s opacity.
Cursor over the "Head" (small black square) will display in the text the value of the "attached" "Body" "Color" instance variable value.

The effect here can be considered as "minor" but actually helps a lot with picking and possibly a lot of new comers will find the using curve of Construct 2 even friendlier.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Fri Nov 23, 2012 10:39 pm

@Julmust - you might be interested in the Pin behavior which can connect objects in the way you describe.

The main difference between families and containers is if you have two big bosses made from lots of objects. Using families, some events might affect both bosses when you only want to affect one. Using containers everything works like it should.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sat Nov 24, 2012 7:37 pm

@Ashley
I'm starting to suspect containers in my construct (110.2) is bugged out and probably the source of my confusion. Can you take a look at this scene and tell me this is normal behaviour? :)

https://dl.dropbox.com/u/4898391/container_test.capx

When you run the cap, is the output the same as this image? https://dl.dropbox.com/u/4898391/containers.PNG

Why is one family member added to the hotspot of some of the other members?

Thanks for all the hard work you put into Construct 2, I don't mean to be ungrateful for all the shiny features. I'm trying to solve a problem I've had with all game making software since, well, ZZT; re-usability and prefabing.Julmust2012-11-24 19:49:17
B
16
S
6
G
6
Posts: 100
Reputation: 4,840

Next

Return to How do I....?

Who is online

Users browsing this forum: blackhornet, mjj1990 and 8 guests