My aim is to create identify a piece of code that increments a number by 1, every 1 second:
We shall call our base number indexVariable, I then want to: indexVariable = indexVariable + 1 every 1 second; until my indexVariable has reached 360 – then I wish it to reset to 1 and carry out the loop again.
How would this be possible in Javascript? – if it makes a difference I am using the Raphael framework.
I have carried out research of JavaScript timing events and the Raphael delay function – but these do not seem to be the answer – can anyone assist?
You can use
setInterval()for that reason.edit: the code for your your followup-question:
I’m not entirely sure, how your rotate works, but you may have to store the degrees in a var and increment those var too like in the example above.