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?
I think you could actually consider a family a type of container.
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.
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 :)
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.
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.
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.
That is hell of an awesome feature !
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.
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.
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? :)
When you run the cap, is the output the same as this image? 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.
Thanks for the clarification. I'm starting to suspect I have a bugged version for some reason :)
Julmust: It works as intended. Your version is not bugged.
Sprite7 is a "end of cliff" and Sprite5 is a "ground tile".
Sprite5 contains Sprite7.
In the layout you have two Sprite7 for four Sprite5.
So when you launch your project, due to the nature of containers, the missing Sprite7 are automatically spawn in the layout.
Hopefully this modified capx will help you visualize the action of containers.
It is your project with simple events to hopefully make sense of what's happening.
When you put your mouse cursor over a Sprite7 the opacity of the associated Sprite5 is modified.
Kyatric Oooooh I see... Of course. That was the distinction from families I was looking for. I thought it worked like how Construct generally work (you have to have at least _ONE_ instance of the object in the scne) but with Containers you have to have atleast one instance of each object referencing it. gotcha. Thanks for your time and effort :)
Sorry for resurrecting an old post. But I had few questions on Containers too. I have a Container with sprites having different frames, say base sprite with 2 frames for Red and Blue soldier, Helmet sprite with again 2 frames fir Red and blue respectively.
I place the 1 Red and 1 Blue Base sprite on the layout at design time. When the game is run, I want the Red base to get teh red Helmet and similarly Blue base to get Blue helmet. How can I achieve this?
Develop games in your browser. Powerful, performant & highly capable.
SamRock: Compare the frames of the Base and set the same frame in the Helmet.
Or even better, consider setting your images in different animations ("Blue" and "Red" for example).
If Base animation is "Blue", set Helmet animation is "Blue".