variables updating when game is closed

0 favourites
  • 5 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hey everyone, just a general question here..

    Lets say that every hour you want to add 1 to a variable but you want it to update even when the app is closed...

    My logic would be ...

    On app opened -> get date and time

    On app closed -> store current date and time

    On app opened -> Do math and work out how many hours have passed -> add to variable

    Is this possible in construct ?

    Thanks !

  • yes it is possible. you would have to be able to save locally to add that feature. save on complete / quite layout - On start / load compare save status and adjust by time. before game resume.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • yes it is possible. you would have to be able to save locally to add that feature. save on complete / quite layout - On start / load compare save status and adjust by time. before game resume.

    I tried using the "Browser.ExecJS("Date()")" but I am unable to get extract an actual value from it.

  • it would be time + 1 for every x sec of time = new variable it won't be able to be saved as a date/time variable in stead as a number. Just like a bonus timer in seconds.

    So to set the variable it would be something like (d= +h= +m= +s= )= gamesaved

    Thus gamesaved would look like

    Updated: 03033600

    and if they where to come back in 6 hours it would be

    on load get value (d= +h= +m= +s= )= gameplay

    Updated: 03063600

    compare gamesaved with gameplay

    for every x sec > then gamesaved = timeelapsed +1

    set gameplay to gamesaved

    if object is to move add timeelapsed to direction of move = new position of object.

    Updated: The only issue I with the variable is that every day adds 76, every hour adds 40, minute adds 40. so you would need to adjust for that also.

    I am pretty sure some one has created a .capx that does this exact feature you are looking for.

  • ryrydawg

    This would give the current time in milliseconds:

    Browser.ExecJS("Date.now()")

    source:

    https://developer.mozilla.org/en-US/doc ... jects/Date

    You could also look here for a plugin that also does this:

    viewtopic.php?f=153&t=63492

    If nothing else you'll probably find an example that is helpful.

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