Family.Count problems

For questions about using Classic.

Post » Thu Mar 10, 2011 8:49 am

(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?
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Thu Mar 10, 2011 10:04 am

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.
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Thu Mar 10, 2011 10:10 am

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)
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Thu Mar 10, 2011 1:47 pm

sprite.count +sprite2.count is probably what Tokinsom means.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Thu Mar 10, 2011 1:58 pm

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
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Thu Mar 10, 2011 2:20 pm

You mean completely different object type?
As in a sprite, and a text object in the same family?
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Thu Mar 10, 2011 4:51 pm

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.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Thu Mar 10, 2011 11:06 pm

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
B
3
S
2
G
5
Posts: 351
Reputation: 2,377


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests