public void update(float gameTime)
  {
    if (!isPlaying)
      return;
    //Increase the elapsed time by the time 
    elapsedTime += gameTime;
    if (elapsedTime > timePerFrame)
    {
     elapsedTime -= timePerFrame;
     if (currentFrames == null)
       goToFrame(currentFrame+1);
     else
     {
       currentAnimationFrame += 1;
       if (currentAnimationFrame >= currentFrames.length-1 && isLooping)
         currentAnimationFrame = 0;
       goToFrame(currentFrames[currentAnimationFrame]);
     }
    }
  }