too many variables in a family?

Bugs will be moved here once resolved.

Post » Thu May 17, 2012 5:46 am

OS - WindowsXP Service pack3
GPU - ATI HD4830

I'm not really sure if this was a bug, but after extensive testing, I think when there are too many variables placed in a family they stop working.

You can see, the events are very simple, but family1 doesn't work while family2 does. I think it also has something to do with the create event as if you remove the create event then family1 will then work.

I noticed this when my new events with pretty much the same code except for some small changes just stopped working. So I used some text boxes for debugging and to further prove this theory I create a blank new file.

Hope this helps.

Tested on both Chrome and firefox (latest)

Here is the capx
http://dl.dropbox.com/u/57137706/toomanyvarsinfamily.capx

Kind Regards.

B
25
S
161
G
3
Posts: 51
Reputation: 18,702

Post » Thu May 17, 2012 9:43 am

The code is simple enough, but it's not obvious what it is supposed to do.
Also, nowhere in your code do you refer to families, only object types.

Replace the event4 condition with
Mouse: on object clicked on Family1
and also replacing the actions that display the Sprite.VariableX to displaying Family1.VariableX

Modified capx

When you create a new instance of Sprite by drag-droping (strange way of doing to by the way, the drag drop behavior allows you to use a "on start of drag" and "on drop" conditions, suppressing the need for the mouse plugin) Sprite2 and then click on the newly created instance, it displays correctly the values of variableX.
You can notice in the code, I haven't switched all actions to Family1.VariableX, and those still relying on a direct call to Sprite only display a 0.

I don't know if it indeed displays a bug where a family variable is seemingly applied to an object type but can't be accessed directly from the object type, or if picking a family in condition is buggy and trying to access an object type amongst the picked instances doesn't work.
I hope @Ashley can bring some clarification there and see if there is indeed a bug or just misunderstanding.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Thu May 17, 2012 2:59 pm

I can assure you there is no limit on the number of variables you can use anywhere in Construct 2. Are you sure this is not just a problem with your events?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Thu May 17, 2012 4:17 pm

Ah sorry I wasn't clear enough basically in the capx press A and you can see the values will appear like they should in the text boxes. Now disable this event and enable the event above which states keyboard on A pressed.

The values in the text boxes don't change at all. The code for both the events are identical with it first creating an object then adding a number to a variable the only difference is that there are more variables in the event above.

I'm pretty sure its not a event problem as when you do the test you will see sprite3 adds fine but sprite doesn't which is in a family.

Thanks for the tip Kyatric, I thought you needed both. RockmanZero2012-05-17 16:33:57
B
25
S
161
G
3
Posts: 51
Reputation: 18,702

Post » Thu May 17, 2012 4:34 pm

[QUOTE=Ashley] I can assure you there is no limit on the number of variables you can use anywhere in Construct 2.[/QUOTE]

I have no doubt about it. I think the original issue here is about instance picking.

My concern is more about what happens in that event:


Considering that "Sprite" is a member of "Family1".
There's already an instance of Sprite on the layout which instance variable values are 0.

When I click on an instance of "Sprite" (a newly created one, with affected values to the instance variables (not 0)), the values are correctly displayed when using "Family1.VariableX"

But using "Sprite.VariableX" seems to display the values for the original instance only.
That's quite surprising, since it's in a "On Family1 clicked" and "Sprite" is a member of "Family1".
I'd expect, when I click "Sprite" (but that I used the event "On Family1 clicked"), that "Sprite.VariableX" refers to the instance variable values of the current picked Sprite, not the original instance.

It's obvious that clicking on "Family1", you should use "Family1" in the actions too, but after all, "Sprite" being a member of "Family1", I'd expect the actions with "Sprite" to act on the "Sprite" instances picked, in that case, the "Sprite" instance I clicked on, and refered to as member of "Family1" in the condition of the event.

Am I just missing the point of Families here ?
Are they considered as an object type in their own right meaning that you can pick the family but that doesn't pick the family members by default ?

New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Thu May 17, 2012 4:45 pm

@RockmanZero: In your initial capx, you use a simple condition "On every tick".
Then you refer to a Sprite object.
Due to how events work it picks only the original instance of Sprite (the one that is already in your layout at edittime).
So it is normal that the values don't change.

Also, from one instance to another, you affect the very same values (You start from 0 and add X for each newly created instance)

I'm under the impression that you would expect the values from the instances variables to be different from an instance to another.
You have to code differently then, use some global variables/arrays as reference in between the instances creations.

@Ashley: The previous message was for you.Kyatric2012-05-17 16:45:55
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Thu May 17, 2012 5:01 pm

I'm getting more confused, I just don't see why the events with pretty much the same code works for family 2 but not with family 1. Both sprite and sprite4 are both on the layout too.

I can get around it like you said. But I wanted everything to be tidy.

http://dl.dropbox.com/u/57137706/toomanyvarsinfamily1.capx

OK Ive taken out everything now, press A and press B, what I'm trying to say is why does press A work but press B doesn't?
RockmanZero2012-05-17 17:01:50
B
25
S
161
G
3
Posts: 51
Reputation: 18,702

Post » Thu May 17, 2012 5:01 pm

Families and Sprites pick instances totally separately. So it is actually intended behavior if you make this event:

+ Mouse clicked on Family1
-> Set text1 to Family1.Expression
-> Set text2 to SpriteInFamily1.Expression

then 'Family1.Expression' returns the expression for the clicked Family1 instance, but 'SpriteInFamily1.Expression' returns as if it were an unreferenced object. It doesn't matter that it's in the family, it may as well be a different sprite not involved in the event at all, because families keep their own picked instances. Some users deliberately take advantage of this fact to be able to set up advanced picking, e.g. handling collisions.

Knowing that, perhaps this is not a bug and just a misunderstanding?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Thu May 17, 2012 5:20 pm

[QUOTE=RockmanZero] I'm getting more confused, I just don't see why the events with pretty much the same code works for family 2 but not with family 1. Both sprite and sprite4 are both on the layout too.

OK Ive taken out everything now, press A and press B, what I'm trying to say is why does press A work but press B doesn't?
[/QUOTE]

The events work as they are intended to work.
When pressing A the only text that does change is "Text19" which refers to "Sprite5", the only sprite that has only a single instance.
So the value of the instance variable "sprite5.test2" effectively changes.

When pressing B, you can see the value of Text17 change. (Text17 refers to Sprite3 which also have only one instance)
But the fact that the values changes indicates the event is executed and works.

And when you finaly arrive on the event "On every tick", you only access one instance of Sprite, the original one, which values are 0.

The code works.
I think that what you think it is supposed to do is wrong.

Consider this capx, you will see more values displayed for every new instance made.
The original instance is displayed twice (the first two 0 values of each line).
That's because each tick I need to clear the text object by clearing it first.
Then you see it loops through every instances, and add its own value to the the current line of text.

@Ashley: thank you for the clarification.Kyatric2012-05-17 17:20:46
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Thu May 17, 2012 5:34 pm

Ah I think I get it now, thanks Kyatric and Ashley. Sorry about that.   
B
25
S
161
G
3
Posts: 51
Reputation: 18,702

Next

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest