Family.Count problems

This forum is currently in read-only mode.
From the Asset Store
An educational game for counting pictures. An easy to use template for developers to build larger games
  • (TL;DR = read bold)

    Hey everyone, I'm not sure if this is addressed somewhere, I did have a look around and found some pretty old posts.

    I'm just wondering what's the go with Family.Count?

    I've been using it recently to count all of the objects in a family, and it was actually doing so quite fine (I had read somewhere that Family.Count would return 1 due to you only having one 'instance' of the family object in the game)

    So yeah, it was working completely fine counting all my objects UNTIL I put a different object in the family. Up to this point, all the objects in the family were different instances of the same test object and I was coding it with families just to save time for when I do in fact have different sprites in the family. Once I put a different Sprite in there, Family.Count ONLY returns 1.

    I know I'll probably have to do a For each addition thingy in the meantime, but I kinda don't think the .count function should work completely fine in one case and then break in another...

    Any help?

  • If you have more than one object in a family, family.count will only give you the # of instances of one of those objects. All I can think of is adding up the object.count for each object in the family.

  • I haven't tried it yet, but I would imagine a

    For each FamilyName

    Add one to some variable

    would work, but it's just odd that it works fine with one object in the family and breaks when there's more than one

    (By one object in the family, I mean there is one object that I've used many times, I intend to put many different objects in this family)

  • sprite.count +sprite2.count is probably what Tokinsom means.

  • Ah I get it.

    The for each method works a little better for what I need.

    Thanks for your input guys

    The actual counting isn't the real issue for me here, it's that I really thought Family.Count should have done it, the weirdest part was that it DID do the trick fine, until I added a different object to the family. I don't actually think families are supposed to behave this way, correct?

    I haven't submitted it to the tracker or anything as yet because I haven't been around here a lot recently so I'm not entirely sure if this has been addressed yet and I'm posting to see what other people have to say about the issue. If other people are having issues with it, I'd glady pop it on there

  • You mean completely different object type?

    As in a sprite, and a text object in the same family?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's a bug/design flaw. Don't bother reporting it, they already tried to fix it and realized it was a problem with the way it was designed, and would have been too difficult to fix for C1.

  • Ah rightio

    That's a real drag then, thanks Arima

    Yeah Newt, let's just say I'm using one 'Box' Sprite but using families to do all the coding for it and the .Count would work fine, as soon as I did something like add another sprite, 'Box2' for example, the .Count would fall over and only return 1

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