How do I track time spent by user in each screen?

Just started using Construct 2? Post your questions here

Post » Wed Nov 12, 2014 11:11 am

Hi,

I want to record the time taken by user to complete the task in each screen. how can I do that ?

Thanks,
Sarthak
B
4
Posts: 2
Reputation: 206

Post » Wed Nov 12, 2014 2:22 pm

Hi!

I didn't understand exactly what you mean, I made this, tell me if can help you

TimeRecord.capx
You do not have the required permissions to view the files attached to this post.
B
17
S
3
Posts: 62
Reputation: 1,054

Post » Wed Nov 12, 2014 11:11 pm

Make a variable called "timeOnScreen"

(system) every 1 seconds -> add 1 to "timeOnScreen"
B
87
S
44
G
16
Posts: 1,009
Reputation: 17,946

Post » Fri Nov 14, 2014 4:50 am

Yes. Thanks a lot .
B
4
Posts: 2
Reputation: 206

Post » Sat Nov 22, 2014 8:24 pm

Hi @justifun. If you want a little more accuracy you could get the time at the START of each layout and calculate the difference. That way you'll avoid the rounding down gap inherent in the solution proposed by @justifun - although if you're not too bothered about partial seconds that solution will serve just fine.
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Sun Nov 23, 2014 5:41 pm

You could even do "every 0.1 seconds, add 0.1" for a more accurate time. The project also has an internal timer that starts as soon as you launch the game, but that cannot be reset between layouts.

I also found that using a very low number like "every 0.01, add 0.01" would not work as intended and tracks time slower than the project's own clock. I'm not sure if this is a bug, 0.02 still worked fine.

I made an example to test it, the 0.01 shows time slower than the rest on my end:
https://dl.dropboxusercontent.com/u/191 ... index.html

Does it happen for you too? I'm not sure it's supposed to be this way.
B
75
S
29
G
17
Posts: 256
Reputation: 15,250

Post » Sun Nov 23, 2014 7:29 pm

Xavier wrote:I also found that using a very low number like "every 0.01, add 0.01" would not work as intended and tracks time slower than the project's own clock. I'm not sure if this is a bug, 0.02 still worked fine.



I'm not absolutely sure, but I believe this is because 0.01 seconds means it happens faster than the framerate ( more than 60 times a second (0.02 is less than 60 times a second)).
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

Post » Mon Nov 24, 2014 4:34 pm

@spacedoubt is right, every X seconds cannot go faster than every tick, I recommand @hundredfold 's method if you need accuracy (save the reference time, and retrieve the current time by substracting the reference time to the current time when needing it, it being in seconds does not mean it is of a precision of 1 second, just that the unit is the second (1.05 seconds for exemple)).

@Xavier
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Mon Nov 24, 2014 4:45 pm

Thanks for the recommendation @Aphrodite - I think there's also a performance issue here. For example, clocking something every second (or ten times per second for slightly more accuracy) is using a lot more resource than doing it just once per layout.
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Mon Nov 24, 2014 5:05 pm

hundredfold wrote:Thanks for the recommendation Aphrodite - I think there's also a performance issue here. For example, clocking something every second (or ten times per second for slightly more accuracy) is using a lot more resource than doing it just once per layout.


Performances would not be that much hurt I would think, but well, if we can prevent doing a redondant thing by using something the engine actually handle itself, why not do it.(I am more thinking of tool usage rather than performances, as using the tools we are given wisely is actually, from my experience, giving good performances).

You also have the advantage of putting the calcul in a function if you want to, that would return the spent time in second relative to the initial time for exemple, which may make the code clearer to an extend.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest