public String animate (double speedmul) {
        String ret = getCurrentFrame();
        if (running) {
            phase += speed * speedmul;
            while (phase >= 1.0) {
                phase -= 1.0;
                framenr += increment;
                if (!pingpong) {
                    if (framenr >= frames.length) framenr -= frames.length;
                    if (framenr < 0) framenr += frames.length;
                }
                else {
                    if (framenr >= frames.length) {
                        framenr -= 2 * increment;
                        increment = -increment;
                    }
                    if (framenr < 0) {
                        framenr -= 2 * increment;
                        increment = -increment;
                    }
                }
            }
        }
        return ret;
    }