Kevin T.
Kevin T.

Reputation: 29

How to count up (and display the numbers as they are counted) to infinity at a certain rate per second?

Let's say I'm making a farming game and I want a span to read "0 tomato plants" and count up at 4 tomato plants per second. I haven't the slightest idea of how to form this (I'm really new to javascript) and I can't find anything online. Essentially I'm trying to make something similar to Candy Box.

Upvotes: 1

Views: 234

Answers (2)

Jack_of_All_Trades
Jack_of_All_Trades

Reputation: 11468

setInterval(function(){function_to_plant_4_tomatos()},1000);

Upvotes: 1

Jonysuise
Jonysuise

Reputation: 1830

Check the setTimeout() function.

Upvotes: 0

Related Questions