# Create a Counter

Get help using Construct 2

### » Tue Feb 18, 2014 10:57 am

I was wondering how you would create a counter that would count up to the player's score iteratively and you would see it go up from 0, 1, 2, 3. Am I doing it wrong?

B
9
S
3
G
1
Posts: 53
Reputation: 1,296

### » Tue Feb 18, 2014 11:49 am

Simplest way I can think of is:

Create a global variable counter

system every 0.5 seconds
system compare two values counter < score
- system add 1 to counter
- currentscore set text to counter

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Tue Feb 18, 2014 11:57 am

[QUOTE=LittleStain] Simplest way I can think of is:

Create a global variable counter

system every 0.5 seconds
system compare two values counter < score
- system add 1 to counter
- currentscore set text to counter

[/QUOTE]

maxcounttime = 180 (3 sec x 60 ticks per sec)

scorecounter = int(score / maxcounttime)

every tick
sub int(text.text) < score
action: set text.text = int(text.text) + scorecounter

This theoretically would give a 3 second counting function to count from 0 to your score.
I suggest this because, if you would have a very high score, the counting could take long. this function dynamically reduces counting to 3 seconds (180 ticks).lennaert2014-02-18 11:58:41
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,607

### » Tue Feb 18, 2014 12:07 pm

@lennaert

That's why I said "the simplest way", haha..

There's always room for adding extra stuff..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Tue Feb 18, 2014 1:31 pm

Thanks guys. I guess it's the equivalent of a while loop.
B
9
S
3
G
1
Posts: 53
Reputation: 1,296