Total playtime?

Get help using Construct 2

Post » Sat Aug 17, 2013 3:56 am

Is it possible to show the total playtime a player has done? Even after saving a game? Like pokemon or somethin.
B
11
S
2
Posts: 91
Reputation: 1,017

Post » Sat Aug 17, 2013 9:24 am

It depends on the type of save game system you're using, whether or not you'd ever want to pause the clock, and if you ever change the timescale.

The most simple way is to call up wallclocktime, which simply counts the number of real-time seconds the game has been open for. This isn't ideal for some situations, like if you wanted to pause the game in any menus, during cinematics, and so on. It's also not ideal if you're using a custom save system (with WebStorage), as wallclocktime resets every time the game is opened. It will be restored if you use the built-in save game system, though.

I'd suggest that you use a global variable, and increment it by dt every tick in all situations where you'd want to track the total time played. A neat way to display formatted time is with this expression: int((GameTime/3600)%60)&":"&zeropad(int((GameTime/60)%60),2)&":"&zeropad(int(GameTime%60),2)GeometriX2013-08-17 09:25:48
B
57
S
15
G
11
Posts: 912
Reputation: 12,606

Post » Sat Aug 17, 2013 10:38 am

At the end of layout (say your game ends on a "GAMEOVER" type layout... or use your own way" >>> add wallclocktime to LocalStorageThingy.PlayTime


Then display it in your HUD etc.
B
20
S
7
G
4
Posts: 322
Reputation: 4,521


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, FabianB and 51 guests