How do I Create/Display a Clock

Get help using Construct 2

Post » Thu Sep 01, 2016 3:31 am

Hey there,
I am trying to design an ingame clock. Normally I would just go by the current time or played time but I need the world time to be separate from "real life" time. I am thinking somewhere along the lines of 2 real-time hours to complete one 24 hour cycle in the game.

I know that I will have to store the time locally/convert real-life time to game time and I can handle that, no problem. I am just stuck on how to display it as a clock.

I was thinking of setting up a text that would divide the currentTime variable by 3,600 to equal each one hour. Then use the remainder and divide that by 60 to get the minutes. I could set a cap on the time so it would reset to 0 after 43,200 seconds (12 hours). I could also set a boolean for AM/AP so that I can keep track of the day/night cycles.

Blah, I think I am on the right track. Anyone have an opinion or experience making something similar?

Thanks
Stephen
B
56
S
15
G
13
Posts: 826
Reputation: 17,645

Post » Thu Sep 01, 2016 3:44 am

It kinda sounds like you've got it figured out? Which part exactly are you stuck on? I assume you mean digital clock as opposed to analog?
B
86
S
43
G
71
Posts: 601
Reputation: 43,619

Post » Thu Sep 01, 2016 3:48 am

If I'm understanding correctly, it's just a timer which runs ~12x that of normal time?

This might not be the ideal way, but, if I recall correctly when I had a time display I had a sprite font object with several variables (Days/Hours/Minutes). It'd constantly add dt to the Minutes variable, when Minutes >= 60 it'd add 1 to Hours and reset Minutes, etc. To display the time I'd just have it as "Set text to Days ':' Hours ':' round(Minutes)". In your case you can add dt*12 or something.

To make it prettier maybe you can use several sprite fonts to have 0s when the variables are in single digits (e.g. 01:02:03 instead of 1:2:3).
B
52
S
24
G
18
Posts: 295
Reputation: 13,090


Return to How do I....?

Who is online

Users browsing this forum: R0J0hound and 35 guests