How do I calculate ?

Get help using Construct 2

Post » Sat Nov 22, 2014 12:20 pm

My game character is running,jumping etc
Can I calculate run of the animation (total time) ?
(just run,not the author animation )
Click D :Character running ( X seconds )
Click w :Character waiting ( Y seconds )
Click D :Character running ( Z seconds)
How can I calculate X+Z ?
B
9
S
4
Posts: 8
Reputation: 751

Post » Sat Nov 22, 2014 12:41 pm

It's not necessary to sum theses values.

Use a variable to store the seconds

var timeSecondsRun

right arrow key pressed => add 1 to timeSecondsRun
every 1 seconds
B
74
S
13
G
4
Posts: 1,006
Reputation: 8,060

Post » Sat Nov 22, 2014 12:54 pm

Thank you RenatoB
B
9
S
4
Posts: 8
Reputation: 751

Post » Sat Nov 22, 2014 3:03 pm

Hi @Poewang. It depends how accurate you want to get because the solution proposed by @RenatoB would be simple to implement but will suffer from some rounding down problems. If, for example, you run for 1.9 second only the first second would have been registered. For more accuracy you could grab the exact time at the beginning and end of each run session and subtract one from the other to calculate duration and add this number to a variable that keeps a running total for you.
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 25 guests