How to do make Parent - Child work?

0 favourites
  • 7 posts
From the Asset Store
_______ Huge collection of metal fixtures ________
  • Hello, thanks for reading this. I am making a Baa Baa Black Sheep game, where the player sheep is made of a body with its head and 3 parts wool as different sprites, as I need these three to disappear at different checkpoint (Master, Dame, and Little Boy who lives down the lane).

    However I am having a lot of problem to get these sprites to act with its body.

    Previously I tried pinning them. Then after reading some tutorials, I think the best way to do it is grouping them together as parent and child so that they can all behave the same way. I am expecting them to move, mirror, scale, destroy and respawn correctly with its body, automatically. I hope I don’t have to code these for every part.

    This is what I have currently. The child do not move with parent. What did I do wrongly?

  • You need to move all "Add child" actions from event 8 into event 7.

    So first you create a parent object, and then immediately add children, in the same event. Note, that if children objects don't exist, you need to create them too, before adding to the parent.

    Alternatively, you can create hierarchy connections in the layout editor, and then then spawn the parent object with "create hierarchy=yes" setting.

  • Thanks, do you mean this parent child function should be the first event on the event sheet if the other events are related to this?

    I also saw another tutorial that teaches about using Containers. In my case, do you think I should use Parent Child or Container to have all the sheep parts behave the same way?

    Thank you

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No, it doesn't need to be the first event, but normally you should add children in the same event where you create the parent object.

    There are 3 ways to do this:

    1. Create parent and all children objects in an event, and add children to parent.

    2. Put parent and children objects to the same container. Then, when you create parent object in runtime, all children objects will be created automatically. But you will still have to position them and add them as children.

    3. The easiest method - create hierarchy connections between parent and children in the layout editor. Then, when you create parent object instance in runtime and tick "create hierarchy=yes", all children will be created automatically, in their correct positions, and all hierarchy connections will also be created.

  • Thanks, I think I would like to do the easiest method, as I am unsure about the events and I have a limited 50 events as a free member. But where do you mean when you mention layout editor? Is it where I create the scene? The properties menu? The object menu?

  • Select multiple sprites, right-click on the parent sprite and there should be Hierarchy menu. (not sure if it's available in free version)

  • Thanks, I will go try it on my pc, as I can’t seem to select multiple sprite on the ipad. Also I will consider purchasing Construct3 after solving some UI problem. I lost the scaling nodes on the iPad version, I can’t drag and resize my sprites manually, instead have to use the properties menu to do it.

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