public void update(long time){
        if(running){
            if(time - previousTime >= refreshTime){
                //Update the animation
                currentFrame++;
                try{
                    sprite = frames.get(currentFrame);
                } catch(IndexOutOfBoundsException e){
                    currentFrame = 1;
                    sprite = frames.get(currentFrame);
                }
                previousTime = time;
            }
        }
    }