too many variables in a family?

0 favourites
  • 10 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • 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

    dl.dropbox.com/u/57137706/toomanyvarsinfamily.capx

    Kind Regards.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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?

  • 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.

  • I can assure you there is no limit on the number of variables you can use anywhere in Construct 2.

    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:

    <img src="http://dl.dropbox.com/u/36472942/construct/forumhelp/FamilyPortrait.PNG" border="0" />

    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 ?

  • 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.

  • 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.

    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?

  • 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?

  • 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?

    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.

  • Ah I think I get it now, thanks Kyatric and Ashley. Sorry about that.

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