Limiting libgdx frame rate?

Is there such a way to limit the libgdx frame rate?

I had this issue before, and there is a backend in LWJGL that lets you do this, but I’m not 100% sure where it is. quick google search turned up this:
http://code.google.com/p/libgdx-users/wiki/limitFps
if you have any general questions about LibGDX this is a very helpful source.

thanks do you know how to make frame independent movement? I am using this code but its not working :frowning:

		if (X < 300)
			X += .05f * Gdx.graphics.getDeltaTime();

I thought this would work correctly but it isnt… any ideas?

X is the x cordinate of the character

I’m not sure exactly what you’re trying to accomplish? I am assuming that your X is the x position of your character, so going on that, I’d say to avoid using deltaTime to move around on the screen, and instead simply add/subtract in the logic. this works for me, but I’m not sure if its exactly accurate all the time. perhaps someone more experienced with LibGDX can help.

That code looks like you’re going to move thing in one direction. See if Actions classes provide what you need.

I use the physics engine for motion, but I do time based animation and it is smooth on both android phone and desktop:

    private boolean processAnimation() {
        if (_animationSpeed == 0) {
            return false;
        }

        if (!_animate) {
            return false;
        }

        final double timeDiff = System.currentTimeMillis() - _lastTime;
        if (timeDiff < _animationSpeed) {
            return false;
        }

        _lastTime += _animationSpeed;
        if ((++_currentFrame) >= _totalFrames) {
            _currentFrame = 0;
        }
        return true;
    }

It ++s to ensure that if a frame gets skipped due to time delay it will keep incrementing frames until we get to where we are supposed to be (I guess the ‘tunnel’ effect, but with animation).