How do I access child objects?

0 favourites
  • 4 posts
From the Asset Store
Add emotion, innocence, joy and cuteness to your video game with these 15 songs and 9 SFX
  • I am using hierarchies to make widgets that display various object attributes.

    Given a parent picked by IID, how do I access the children?

    Manipulating the parent works fine. Manipulating the children affects all instances in the game.

    Do I need to pick the children explicitly or are they accessible when the parent is selected. Should I store the children's IID/UID in a parent instance variable for later access?

    The above image shows the parent (center) and it's children. Most children need to be manipulated (visibility, text, angle, ...)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If they are different objects, then it's easy - you pick the parent instance, pick children. You can filter the picked children further, for example by animation name:

    SpriteA pick by IID
    SpriteA pick children SpriteB
    SpriteB animation "foo" is playing
    

    If the parent and children are instances of the same sprite, you need to use a family:

    Family pick by IID
    Family pick children Sprite
    

    You do need to pick children explicitly. You don't need to store child IID/UID.

    By the way, picking by IID is not recommended, as this value can change in runtime.

  • I think I am getting there. Not sure if I missed this in the manual, but I would have never figured this out without your help.

    The following seems to work. Still having trouble with one of the gauges, but I am hopeful to figure it out.

    I can now individually change the gray widgets' attributes:

    This is the code:

    Did I do it the right way (best practice)?

    I assume that IIDs don't change unless you switch layouts and create a bunch of other objects. How else would I be able track objects?

    Thanks for your continued support :)

  • I assume that IIDs don't change unless you switch layouts and create a bunch of other objects. How else would I be able track objects?

    Lots of ways - by instance variables, by tag, by animation etc. You can add the slider to the hierarchy, and then pick its parent/child WID_USE object. Or you can use containers.

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