# How do I change number of balls text if player misses

Get help using Construct 2

### » Thu Aug 17, 2017 6:58 pm

Hey all. Say I have a basketball game where the player has to shoot the basketballs into the net in order to score and there is text of 3 shown in upper left hand corner. How can I make it so that if the player misses the basketball net with the ball, the 3 shown will change to 2 indicating the player has 2 more balls left....then if he misses another basketball shot the 2 text will change to a 1 shown and then if he misses the next shot, the 1 will change to 0. Could someone please post a capx illustrating this?
B
12
S
3
G
3
Posts: 36
Reputation: 2,274

### » Fri Aug 18, 2017 11:51 am

please post a capx illustrating this?

Share a basic capx, with the basic setup, and i will add to it.
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Fri Aug 18, 2017 5:32 pm

apalm1341 wrote:Hey all. Say I have a basketball game where the player has to shoot the basketballs into the net in order to score and there is text of 3 shown in upper left hand corner. How can I make it so that if the player misses the basketball net with the ball, the 3 shown will change to 2 indicating the player has 2 more balls left....then if he misses another basketball shot the 2 text will change to a 1 shown and then if he misses the next shot, the 1 will change to 0. Could someone please post a capx illustrating this?

1-Create a global variable representing the number of balls you have (3 in this case) and name it BALLS
2-Set a local variable to the ball and set it to 1 if it goes in,
3.a- if it does not go in, of course you leave it to 0...
3.b-if the ball hits the ground or falls beyond a certain "Y" value and its variable is =0, than you remove 1 to the global variable BALLS.
After that, set the text to "balls left"&BALLS...
''''
B
28
S
11
G
3
Posts: 114
Reputation: 3,885