Trouble with creating a time-based mechanic

0 favourites
  • 3 posts
From the Asset Store
Human/Character Base Pixel Art Sprites in various poses (nearly 100 files)
  • I'm currently in the process of creating a Tamogochi type game, and I'm trying to nail down the mechanic where the program calculates how much time has passed since you've closed the game and subtracts from your pet's stats accordingly. However, every time I get the function I made to trigger it just sets everything back to zero and messes up my hygiene mechanic.

    Does anyone have any suggestions on how to properly create this mechanic?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi,

    you can use the Date plugin to get the "Now" expression. It's the number of milliseconds since 1970. So it always increments; If you save it when closing the app using local storage, and you get it again when the app opens again, you can subtract the new value from the saved value to know the time that passed since the last time you opened the app.

    See my little video on the date plugin en the "Now" expression on my youtube channel.

    The channel has many tutorials on how to create games, and i'm planning on adding an idle clicker game or something any time soon that will use the same mechanic.

  • Thank you, that seemed to have worked.

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