How do I move all the objects of a container all together?

0 favourites
  • 9 posts
From the Asset Store
A well commented Dynamic Heart Containers template to learn from or to use as a base for your own game!
  • My game has an object container made of 3 sprites. Basically, it's a big sprite with two sprites pined on it acting as buttons.

    At certain times of the game, when clicked, I need the object to :

    1) move in front of other objects on the scene

    2) move to another layer.

    So I send the commands to the main element of the container and find out that

    1) only the main element is send in front

    2) only the main element is sent to the other layer

    I thought that when an order was sent to the main element of the container, the whole container would act accordingly to and behave as a single object. ie, when main element is sent to front, all the object elements would be sent to front and be rearranged. The same when the main element is sent to another layer. All the elements would follow and be put at the right place and zindex.

    Is there a simple way to fix this ?

    Tagged:

  • When changing z-order or moving to another layer, you need to do this for each object in the "container".

    If you need to do this often, you can make an event which moves all child objects above the parent object on every tick. Also I suggest using hierarchy instead of pin.

    For each Parent
    Parent pick all Child : Child move in front of Parent
    
  • When changing z-order or moving to another layer, you need to do this for each object in the "container".

    If you need to do this often, you can make an event which moves all child objects above the parent object on every tick. Also I suggest using hierarchy instead of pin.

    > For each Parent
    Parent pick all Child : Child move in front of Parent
    

    Thank you !

    Actually, I've to do it quite often with many different containers.

    I tried your method but couldn't find the action "Child move in front of Parent"

  • couldn't find the action "Child move in front of Parent"

    Sprite -> Move to object

    There will be options - move in front, or behind.

  • Got it. But how do I do if I have many children attached to the main object of a container and many container (that don't share the same objects)

    Here's a quick sketch of how it looks like

  • Like I said, use the hierarchy. You can either create it manually in the layout editor, or programmatically with events.

    construct.net/en/make-games/manuals/construct-3/interface/layout-view

    If you prefer Pin, you can pick pinned objects using System Pick By Evaluate expression, where Child.Pin.PinnedUID=Parent.UID

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I had a long look at hierarchy and yes, it looks like very powerful and useful feature.

    According to the drawing I posted before, let's say that Blue square and Yellow square are part of a family called Square and every sprite children's name would be the number/letter they have (so Sprite.A, Sprite.B, Sprite.1, Sprite.2) . Would your previous code be :

    -For each Square

    Parent pick all Child : Child move in front of Square

    I found Child "Parent pick all Child" condition but not "Child move in front" action

  • If you have Square family and Circle family, then the code will be:

    For each Square
    Square pick all Circle children
    ...Circle Move in front of Square
    
  • I have to thank you very much for pointing me into the Hierarchy direction. I haven't paid attention to it so far and I discovered a whole new world.

    Thank you ! Now it works

    For anyone interested, here's a commented project file

    https://www.dropbox.com/s/hkw9g396zrnw5ha/DragAnimationLevels.c3p?dl=0

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