Help Coins and Instanced Objects

Get help using Construct 2

Post » Tue Mar 08, 2016 2:11 pm

Hello,

I have a global variable called Coins
When I right click I spawn an instanced object
When I right click I subtract 5 coins from the global variable Coins

The trouble is I can right click as many times as I want and it keeps subtracting coins and placing the objects down.

How can I prevent this ? Basically what I want is that when the global variable of coins is less than or equal to XX don't subtract anymore coins from the global variable and certainly don't spawn another wall ... :(

Thanks!
B
3
Posts: 1
Reputation: 177

Post » Tue Mar 08, 2016 4:33 pm

This is a beginner question, right?

If right click & global variable coins > 5, create wall.

https://www.scirra.com/forum/beginner-s-questions_f178
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 963
Reputation: 10,721

Post » Tue Mar 08, 2016 8:13 pm

Or you can use "Set" instead of "Subtract"

Code: Select all
Set variable -> max(variable - 5, 0)

Max, Min and Clamp are math functions you can use if you want to set limits to your value.

Max(a, b) where a is your value, and b is the lower limit
B
84
S
22
G
15
Posts: 1,039
Reputation: 15,249


Return to How do I....?

Who is online

Users browsing this forum: luckyrawatlucky, nahima, Yahoo [Bot] and 8 guests