How to remove variable value, when just a collision

Get help using Construct 2

Post » Wed Mar 19, 2014 6:13 pm

Hello,
I'm making a game in which the user assembles his plate.
Every time he puts the food on the plate, add a value to the variable. Until then OK.
The problem is that when an item retreat of the dish, I can not subtract the same value that was added to the variable.
I am attaching the code I did.
Thank you very much
You do not have the required permissions to view the files attached to this post.
B
4
S
1
G
1
Posts: 6
Reputation: 494

Post » Wed Mar 19, 2014 6:50 pm

"else" does not pick instances and the way you have implemented this else cancels the above sub-condition since it is nested under "on collision" so it will run if the above it is true.
try using an instance variable to check things
B
15
S
6
G
4
Posts: 277
Reputation: 3,948

Post » Wed Mar 19, 2014 7:18 pm

Able to resolve this problem, but another appeared.
If you click and release several times into the dish, and it keeps adding points out, subtract the same way.
Is to create a way to specify that it can only add 1 point?
You do not have the required permissions to view the files attached to this post.
B
4
S
1
G
1
Posts: 6
Reputation: 494

Post » Wed Mar 19, 2014 8:40 pm

If you want alimentoX to be able to be put in the plate only once, you can use some global variables to check if that alimento has been already put in there.
For example, alimento1alreadyUsed, than you need to check if this var is false when you drop the alimento over the plate, and then set it to true when adding 1 to proteinas.
If you have lots of 'alimentos' I recommend using an 1D array or dictionary to keep track of which one has been already used.
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

Post » Fri Mar 21, 2014 1:12 pm

Thank you all for your help.
I was able to do what I wanted, using conditions.
You do not have the required permissions to view the files attached to this post.
B
4
S
1
G
1
Posts: 6
Reputation: 494


Return to How do I....?

Who is online

Users browsing this forum: blue visionary, OBLIVION and 15 guests