Problem with Family instances

0 favourites
  • 5 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Hi all, I hope you can help me with a problem I have been having using Families and instances.

    On this link is a simple test case I have created to demonstrate the problem:

    FamilyTest.capx

    This is not exactly what I am doing in my actual app but it shows the issue nicely.

    In this example I was expecting it to show me the UIDs of both the sprites in 'Family1' but it only ever shows the the UID of the sprite with UID zero.

    Surely the 'is visible' event should pick both instances in `Family1`?

    Any help with why it does this or what I am doing wrong would be much appreciated.

    Cheers,

    RR

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Add 'for each family1' after the 'is visible' condition. Right now they are both selected, but only first one of the picked objects is referred.

  • Thanks vee41, that sorted it, very much appreciated.

    I just tested it with sprites not in families and noticed it requires the same, I am amazed I got this far without hitting this before.

    I also spotted that if I put in, say, a rotate action instead of the text setting it acts on both sprites, could you explain the distinction (IE why one action needs the loop and the other does not)?

    Cheers,

    RR

  • That is explained in detail in the for each tutorial.

  • Thanks Arima,

    Coming from a traditional coding background this is making my brain twist around a bit.

    It looks to me like any action that changes an object will act on all picked instances, while any action that needs to access the objects properties needs the loop (so it knows which one it is getting the data from).

    Cheers!

    RR

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