How do I choose from a family a specific sprite to add to a hierachy ?

0 favourites
  • 5 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • In my game, I've a sprite named "card" with hierarchy and need to add children runtime. The children will be taken from a Family named "External modules".

    I've tried a test with a sprite named "test". It works

    Point is that when I replace that sprite with family, a random family sprite is created. How can I choose the family member to display ? (actually, I'd like to show a template)

    Tagged:

  • The only way is to add all such objects to a family, pick family instance by ObjTypeName and then add this family instance to the hierarchy.

    System pick by evaluate Family.ObjTypeName=variable
    
  • Hi dop2000

    Thanks !

    I've slightly modified my question since you answered.

    I've tried your formula by checking templateName but it doesn't seem to work..

    Is it possible to pick a family membre before creating it ?

    Besides this family problem, what I need is :

    - create a given object from data taken from a JSON (actually an object used as a template)

    - add this object (template) as a child to another object.

    And it seems that :

    - I can create a object by name

    - I can't add an object by name to another object.

    Hence my attempt of a workaround using families

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • OK, I managed to get it right on my side :

    - A, B, C are in Family.

    - Runtime operation state that B has to be created.

    - B is created using Create object by name.

    - Last created object from Family is picked (B, because B is in Family and B is the last created).

    - Picked Family member (ie B) is added to hierarchy.

  • ObjectTypeName, not TemplateName.

    Here is what I meant:

    Pick BodyPartsFamily where BodyPartsFamily.ObjectTypeName="Head"
    Body add child BodyPartsFamily
    

    This will attach Head to Body in the hierarchy.

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