Run while off
@CodingCactus in your cactus clicker, how did you make it run while the user wasn't on the tab?
Voters
InvisibleOne (2674)
If the tab is open it should be running, it should only stop if you close the tab
2plus2is4hoi (94)
do ctrl + u in the tab and you can see the source code
it isn't running, it just calculates how much time it has been since you last were on the site (using local storage) and then uses that to see how many cacti you would have got in that time : )
Can you teach me how to do that? @CodingCactus
@WilliamXing take a look at the code
I'm not exactly a JS pro, so could you tell me? @CodingCactus
@WilliamXing What he's saying, is to put the current time in local storage.
localStorage.setItem('time', whatever_the_time_is)
Then when you reopen the page, take that time and the current time now. Remove the old time from the new time to tell how much time has passed. Once you know how many seconds have passed, you can easily multiply that by the amount of cacti/points you get per second, then add that to your score.
How do I make the "Whatever the time is" and the "What time is it when the user opens it"? And, how do I do the subtraction? @InvisibleOne
@WilliamXing
Whatever the time is
Saving that to local storage
Then getting that value
Subtraction
With the time