Refactored the animation code into ccanimator.js