How do I assign container instances in the layout editor?

0 favourites
  • 5 posts
From the Asset Store
Array Editor
$1 USD
80% off
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • This one still baffles me somewhat.

    If I place multiple instances of Sprite1 (container) in the layout at random locations, and then multiple instances of Sprite2 (included in the container), how will the editor decide which 2 should belong to which 1?

    Or will it delete all 2's and spawn new ones at 1's centers?

    And also, if the latter is true, then does all positioning with multiple instances need to be done via events, or can I make sure specific 2's belong to specific 1's using only the layout editor (so that it doesn't create new ones at center points but keeps existing ones where they are)?

  • construct.net/en/make-games/manuals/construct-3/project-primitives/objects/containers

    Placing objects in a container has the following effects:

    If one object in a container is created, every other object in its container is also automatically created.

    If one object in a container is destroyed, every other associated object in its container is also destroyed.

    If a condition picks one object in a container, every other associated object in its container is also picked.

    For each instance of sprite 1 you create, a sprite 2 will also be created and associated with a sprite 1.

    For each instance of sprite 2 you create, a sprite 1 will also be created and associated with a sprite 2.

    Positioning should be done with events upon creation. In the same event as creation, the relevant instances of sprite 1 and 2 are both already picked.

    Edit: Missed the part about placing in the layout editor, so see the more accurate answer below.

  • This isn't quite accurate. While the documentation implies that is how it works, it actually considers items from the same container placed in the editor as joined together. The order you place then on the editor decides which items are in the same container. For instance, of you place 1 copy of sprite1 and the 1 copy of sprite2, they will be joined together. This is because, on start of layout, those items are created at the same time meaning they are created together. This can be tested by setting your container selection mode to select all. You will see that both items will be selected.

    All items in the container will be associated with other items in the container according to the order you place them in the editor. First sprite1 with first sprite2 and second sprite1 with second sprite2, etc...

  • Yes I thought the doc wasn't saying everything. So it's the order of creation that matters.

    Whereas this makes sense when copy-pasting multiple instances of the container; it is also rather inflexible, i.e. not controllable after the fact (no way to assign a predefined child to an arbitrary instance when a bunch of them have already been created).

    So in the end it would seem it's best to just create/position in runtime.

    Thanks!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I think its the case that objects in a container have the same IID. So you can use that for picking to differentiate between containers.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)