Family Scope & Family Count inside loop

0 favourites
  • 7 posts
From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies.
  • Problem Description

    Don't know really if this is a bug or a C2 expected behavior. I know there is some particularities about "create objecto scope" but I couldn't find the right answer or similar posts about it.

    So, the thing is that Family objects list is not properly updated when creating Family objects inside a loop and you want to use the new members with "Family actions" but this "problem" is not coherent with Family count because it does count the new members.

    It happened in one of our projects so I prepared a blank C2 project to "prove it". If this is not a bug, at least will be useful to understand this kind of C2 behavior.

    Attach a Capx

    https://www.dropbox.com/s/qt3bi89asjpp5 ... .capx?dl=0

    Description of Capx

    Use of destroy only to prove that Family was not updated after loop finish and the Family count is wrong (?)

    Steps to Reproduce Bug

    • Just play the project.

    Observed Result

    1. Only two squares (blue ones) are destroyed, even if a lot of Destroy action types are after or inside the loop.

    2. Family.Count counts 8 squares even if it does destroy two of the squares (blue ones).

    3. Only a wait action seems to work with Family objects updates.

    Expected Result

    1. All squares are destroyed.

    2a. Family.Count inside loop: 4, 2, 2

    2b. Or Family.Count inside loop. Being coherent with the problem about not destroying all squares: 4, 4, 6.

    Affected Browsers

    Not important.

    Operating System and Service Pack

    Not important.

    Construct 2 Version ID

    239 & 243

  • Ashley can you help me with this?

    What Am I doing wrong?

  • I think that the 'sprite.count' expression always counts the newly created objects.

    'Sprite.PickedCount ' Is not counting in the newly created objects before using a new root event, because it depends on a pick condition. 'sprite.count' Does not depend on a pick condition.

    That "create object scope", you talk about, is all about not able to pick newly created objects. (except by UID) before the next root event.

  • Here are two posts that explain how picking works with created objects:

    It doesn't explicitly mention families but the created sprites aren't added to the family to be pickable until a top level event as well.

  • It doesn't explicitly mention families but the created sprites aren't added to the family to be pickable until a top level event as well.

    I did think of that for a moment, but I got confused when the "wait and destroy" in the same scope worked.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This would not work if the created sprites aren't added to the family to be pickable until a top level event ?

    (Thats is just a question)

    https://www.dropbox.com/s/u23pivjynifv9 ... .capx?dl=0

  • After a wait the object scope is re-evaluated. The newly created sprite is still picked but all the family will be picked because you didn't explicitly pick any family instances.

    Consider the three examples below. When you don't explicitly pick an object type it assumes all of them are picked. The first two examples both just destroy all the family instances after the wait. The third picks a family instance, so that is remembered after the wait, and only that instance gets destroyed.

    start of layout
    --- create sprite
       blank-sub-event
       --- wait
       --- destroy family
    
    start of layout
    --- create sprite
       pick all family
       --- wait
       --- destroy family
    
    start of layout
    --- create sprite
       pick family instance 0
       --- wait
       --- destroy family[/code:2y9fpuz1]
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)