How do I create, at start of layout, every object contained in a family?

0 favourites
  • 10 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • My game is an empty scene when layout starts.

    All my objects to be displayed are in a family and they re a lot.

    At start of layout, how do I tell Construct to look into Family and create each object at the centre of the layout(x=layoutWidth/2, y=layoutheight/2) ?

    Tagged:

  • To create each object in a family you need to make a create action for each object. Alternatively you could place them in the layout yourself to avoid making the events.

  • To create each object in a family you need to make a create action for each object. Alternatively you could place them in the layout yourself to avoid making the events.

    is it not possible to have something like :

    - for each object in family

    - create object on layer 0 at x=150, y=150

    I've quite a lot of object in the family and would like to automatize the creating process to save time and have a simple method if I have to make changes (for example the coordinates)

  • For the creation no but if the problem is with the co-ordinates then that's fine. You can create all the objects with separate actions, then the set position you can use the Family, it will move all the objects with one event.

  • When you write action, you mean one action per object in the form of :

    - create Object 1 at X,Y

    - creaste Object 2 at x,Y

    etc, as many lines as there are objects ?

    No way to make a batch create function ?

  • Well you could do some unnecessary logic like create object by name and have the names ready and run a loop in a function through all the names. But yeah you should do create actions for each object separately. The x,y doesnt matter because at the end you can say Family set position to your co-ordinates and it'll move them all.

  • If all members of the family have names like Obj1, Obj2, Obj3... then you can create them by name:

    For "n" from 1 to 10 : Create "Obj"&loopindex

    Another workaround is to manually create a hierarchy with all family objects on an unused layout. Then you can spawn this entire hierarchy in runtime, which will create all objects at once.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If all members of the family have names like Obj1, Obj2, Obj3... then you can create them by name:

    For "n" from 1 to 10 : Create "Obj"&loopindex

    Another workaround is to manually create a hierarchy with all family objects on an unused layout. Then you can spawn this entire hierarchy in runtime, which will create all objects at once.

    do you have an example capx of how to do that?

  • Manually put all sprites from the family on an unused layout. Select all these sprites, right-click on one of them (which will be parent) and choose Hierarchy -> Add selection.

    Then select all children (without the parent) and untick all these checkboxes for them. Because you are using this hierarchy just to create them all at once, you don't want to sync any properties.

    Then use this action to create all sprites at once:

    Create ParentSprite at X,Y Create Hierarchy=Yes

    Make sure you don't have these sprites on other layouts.

  • Thank you all for your suggestions.

    Giving the same name to the objects in the family sounds like a good idea !

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