How do I get the real time from the device?

0 favourites
  • 8 posts
From the Asset Store
A futuristic device, can be used as radarscreen, optionscreen, infodisplay, research device, ...
  • Hi, everyone :)

    I'm creating a game for mobile, and I want to use an "energy system", like the lives in Candy Crush or in other games. The basic idea is you spend energy to enter a level and from time to time, even with the game closed, the energy is replenished. I've learned that you can get the time of the device with the Browser Object. But I'll build the game with Cocoon, and I've heard that the Browser Object is not supported for this.

    There's any other way of get the device time/hour than using the Browser Object? Or even, there's any other way of making this energy system? Couldn't find any tutorial anywhere...

    Thanks ^^

  • System has the unixtime expression, so simply typing unixtime will return that.

    There's also a plugin that I made. construct.net/make-games/addons/97/utc-time

    It's basically the same with some extras. In your case you probably won't need them tho.

    Don't forget that the device time can be changed to cheat. If you want to avoid that you have to get the timestamp from a server.

  • WackyToaster

    Could you recommend a good reliable server to get the time from? And how do you do this - with some JS script?

  • Your best bet is your own server, say if you have your website hosted somewhere. There you put a file that does nothing but generate that timestamp and you request that file with AJAX from your app. Should even be doable with some free hosting services.

    For the file you can use php or js, it�s pretty easy to find it on google.

  • Wow, thank you so much!

    I'll do some tests with this expression. Maybe I'll use a server to get the right time. You helped me a lot.

    Thank you again ^^

  • Man... Just realized that I've posted on the Cosntruct 3 Board... Sorry... I'm using C2. This expression seems not to exist on C2. There's still some way to do this on C2.

    (This post can be moved to C2 Forum. Sorry for the mistake)

  • * moved from C3, as per request.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • For C2 use Rex's "Date" addon, you can find it here:

    c2rexplugins.weebly.com

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)