0 Favourites

Many variables for many clones of sprite. (Solved)

This forum is currently in read-only mode.
  • Hello.

    I'm new to this forum and construct.

    I am trying to create a small "game management" and I need your help on a problem I encounter.

    I have a sprite (called "miner") that is automated based on several variables such as "Thirst", "Hunger," "Sleep" and other.

    When these variables, a condition managed by "Time" reaches a certain value, my "miner" moves respectively sprites "Water," "Food" and "Bed" for example, which has the result, the duration it overlaps the sprite, to increase the values of variables ...

    So far, no problem ...

    My worry is that I want to create an infinite number of clones of my sprite "miner" but when I did it with private variables (or global), they obviously share the same variable.

    So I test it with a "Hashtable" and by putting an object ID, but they share the same key (it's hard for me as a beginner to understand this stuff).

    In short, it does not work!

    Do you have a solution?

    The hash table is it the right way and if so, how to set up for me?

    Thank you in advance.

    PS: It's been three days that I have tested everything and looking for a solution on the forum posts but I think not or do not understand what is being proposed, so excuse me if a solution has a similar problem has already been posted and I have not seen.

    And my apologies for my English (it must then blame google translate;)). <img src="smileys/smiley9.gif" border="0" align="middle" />

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • My worry is that I want to create an infinite number of clones of my sprite "miner" but when I did it with private variables (or global), they obviously share the same variable.

    Private variables work fine with different instances of the same sprite. They're not automatically the same throughout all instances. Just drop a few instances of a sprite in the editor, give it a PV and set different values. You'll see it'll stay individual for every instance.

    So yeah, you don't exactly need hash tables, unless you want to add and remove variables at runtime.

  • Pfffff ...

    So I think a timeline history of conditions / actions caused the mess in my variables (or so I was doing anything with my event sheet is very possible ...) because your post forced me to redo everything and it works perfectly!

    I knock myself so everything is clear to me now.

    So thank you very much.<img src="smileys/smiley4.gif" border="0" align="middle" />

    PS:

    I leave the cap as an example if it can help a beginner like me who goes through here.

    dl.dropbox.com/u/35730211/exemple.cap

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