Create Family Object with Multiple Instances

  • I'm looking a quick solution how to create a family object once time, i have like 7 different instances are part of this family.

    Each instance has instance variable like name and X & Y positions.

    On Start Layout:

    System -> -Create object MyFamily1

    MyFamily1 -> -Set Animation to MyFamily1.Name

    MyFamily1 -> -Set Position to (MyFamily1.InstanceX, MyFamily1.InstanceY)

    Observed result was it created only one instance, not multiples...

    Thanks!

  • Seems that C2 creates 1 instance because there's only 1 event making it spawn , I recommend using functions , seems like families aren't for spawning ...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Seems that C2 creates 1 instance because there's only 1 event making it spawn , I recommend using functions , seems like families aren't for spawning ...

    Whiteclaws I know. It's already using functions.

  • Uh :D , My bad , could you give me some examples ?

    I meant that you should make a function "family"

    Add all the spawning ( Needs to be separate events ) in 1 function and call it when you need to spawn the many objects

  • It won't work like this because you are creating sprites with

    Color = ""

    PosX = ""

    PosY = ""

    ID = ""

    In your example you are refering to sprites from different layout. But on your current layout Sprite1 have all variables set to "".

  • shinkan Yes i noticed, so don't you tell me what we should resolve this issue?

  • How to pick the instances from another layout?

  • I'll try and resolve it ....

  • I don't think You can.

    one of the solution would be to specify somewhere all attributes for variables

    Family1.id = 1 - > set Color = "blue"

                       set PosX = "123"

                       set PosY = "321"

    Family1.id = 2 - > set Color = "red"

                       set PosX = "567"

                       set PosY = "765"

    ...

    That way family objects with corresponding id number will always have this values.

    I'm not at home at the moment so I can't check for other possibilities.

  • You could make objects in other layouts global and hide them from layouts they are not needed in. I suggest that you find other approach to the problem though (saving in array, passing variables when changing layout for example)

  • I think the instance variables are all set to 0 when the object is spawned and that's why all spawn on the same spot and with the same color ...

    I could be wrong ...

    Try positionning them out of the layout , and just moving them

  • I think the instance variables are all set to 0 when the object is spawned and that's why all spawn on the same spot and with the same color ...

    I could be wrong ...

    Try positionning them out of the layout , and just moving them

    That is correct.

  • I think the instance variables are all set to 0 when the object is spawned and that's why all spawn on the same spot and with the same color ...

    I could be wrong ...

    Try positionning them out of the layout , and just moving them

    Instance id is not unique to an object, it is just an index to selected objects :-) So if picked objects change you cannot use same iid to reference the object anymore.

  • I've read all your posts, so i guess the conclussion is C2 has no way to pick instances from another layout, it was impossible.

    So the workaround to create objects with manual values, it could work and repeat events.

    Thanks!

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