How do I work with timers?

Get help using Construct 2

Post » Wed Mar 05, 2014 11:12 pm

There you go.. I updated the .capx to also do the conversion to days, hours, minutes and seconds for you

https://dl.dropboxusercontent.com/u/2560922/mobiledev/forum/saveTimestamp.capx
As you can see there is no need to store anything else then the unix timestamp.
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Thu Mar 06, 2014 2:13 am

cvp wrote:There you go.. I updated the .capx to also do the conversion to days, hours, minutes and seconds for you

https://dl.dropboxusercontent.com/u/2560922/mobiledev/forum/saveTimestamp.capx
As you can see there is no need to store anything else then the unix timestamp.


OMG. Now I get it!

I don't know what else I can say besides thank you. Perhaps offer you a bitcoin donation for all your help? :)
B
9
S
1
Posts: 51
Reputation: 644

Post » Thu Mar 06, 2014 7:19 am

kkletsgo wrote:I don't know what else I can say besides thank you. Perhaps offer you a bitcoin donation for all your help? :)


:) thx for the offer, but no thanks. I am just happy to help.

I have the philosophy that if I can help answer some questions, then the smart people we have in this forum might have more time to help answer my own questions :D
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Tue May 27, 2014 3:49 am

awesome example ,
but i have a problem. I would like that after two days or twelve minutes was created a sprite in the screen,,,, it´s possible???
i don´t get it.
thanks
B
11
S
4
G
3
Posts: 120
Reputation: 4,058

Post » Wed May 28, 2014 9:45 am

@tchem That should be possible yes.
You can just compare the number of the timestamp to see if it is bigger then either 2 days or twelve minutes, and show the sprites if that is the case.
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Mon Jun 02, 2014 3:23 am

@cvp Thanks man,,,, i didn´t get yet,,,, but i´m trying.... i don´t no how to compare the timestamp with 2 days, by example....is
in this example i did only a test to compare before and after,,,

Image
You do not have the required permissions to view the files attached to this post.
B
11
S
4
G
3
Posts: 120
Reputation: 4,058

Post » Tue Jun 03, 2014 6:30 pm

I dont have C2 available atm. But you have all the information you need available in the attachment you have shown above.

The timestamp is a number. The number is counter of milliseconds since january 1. 1970.

so in a sence you can just record the "start" time as you do on your first click. Like: system -> set date to Date.UnixTimestamp

then you just have to compare you start time to the current time. (if you are comparing in days you should not compare every tick, but at a more fitting interval)

You can then calculate the amount of days that has passed since your your starttime. that would be:

(Date.UnixTimestamp - date)/(1000*60*60*24)

That find the difference in milliseconds between the two timestamps. The last part converts the milliseconds into days. You have all the other conversions available in the text as well if you want it in something else then days.

Hope that helps a bit.
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Previous

Return to How do I....?

Who is online

Users browsing this forum: Nicolas951, Shenkai the ssj, Yahoo [Bot] and 22 guests