If you want to animate different objects throughout the game with proper time interval of time, you can use this code. I've used this in my game to animate balloons and other objects in game.
Also this will help to call different functions at different interval of time.
timer
This small library extends the timer object (performWithDelay, pause, resume, and cancel) to use optional tags.