give a variable a maximum number

Get help using Construct 2

Post » Wed Apr 04, 2012 10:12 am

Hi I was wondering if there is a simple way to give a global or local variable a maximum number level.

E.g. I am creating a tower defence game where your core has 5 lives. but during the game its possible to earn more lives by getting highscores on certain levels. But I dont want the player to get more than 10 lives. So is there a simple event i can add to prevent the lives variable exceeding 10 or whatever amount is decided.

thank you.
B
25
S
7
G
5
Posts: 185
Reputation: 5,056

Post » Wed Apr 04, 2012 10:16 am

You can use clamp expression for that purpose.

For example:
If player overlaps cake then lives = clamp(lives+1, 0, 5)

See system expressions in the manual.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155


Return to How do I....?

Who is online

Users browsing this forum: MarkThomas and 15 guests