Many variables for many clones of sprite. (Solved)

For questions about using Classic.

Post » Tue Jul 19, 2011 3:40 pm

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;)). Anxious2011-07-19 18:46:23
B
4
G
2
Posts: 9
Reputation: 1,243

Post » Tue Jul 19, 2011 4:05 pm

[QUOTE=Anxious]
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.
[/QUOTE]

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.PixelRebirth2011-07-20 17:20:26
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Tue Jul 19, 2011 6:41 pm

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.

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

http://dl.dropbox.com/u/35730211/exemple.cap
B
4
G
2
Posts: 9
Reputation: 1,243


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests