I’m trying to create an animation using HTML5 canvas and Javascript. I have very little prior knowledge of Javascript. The first part of the animation is to make a circle ‘grow’ until the edge touches a cross. The cross then moves along the edge of the circle. Individually, these parts work fine but, as I’m using setInterval(), both animations play at the same time rather than waiting for the first to finish before starting the second.
What would be the easiest way to do this? I would be happy using HTML buttons, but <button onclick="setInterval(aRot,30);">Next Step</button> doesn’t seem to work.
My ‘orrible ‘odgepodge of code is viewable at http://jsfiddle.net/jtYkN/12/
First off you really want to use requestAnimationFrame rather than setInterval. Its made specifically for animations. According to paul irish..
Heres how I would implement what your talking about