1
\$\begingroup\$

I'm making a LibGDX game where the player needs to tap to jump. But in this game, the player has to tap extra fast because the player needs to jump extra fast.

The problem is, the program can't register the taps fast enough to keep up with the user.

I've tried to handle the input 3 times per frame, but that turned out to be very problematic.

public void handleInput(float dt){
        if(Gdx.input.justTouched()){
                player.jump();
        }
    }

@Override
    public void render(float delta) {
        handleInput(dt);
        handleInput(dt);
        handleInput(dt);

        //handle everything else down here

    }

Are there any other ways to handle input at the speed of the user?

\$\endgroup\$
  • \$\begingroup\$ Are you using continuous rendering or request rendering? \$\endgroup\$ – Huxellberger Aug 27 '16 at 14:28
  • \$\begingroup\$ Not sure what the distinction is, but the main class extends Game and the others are screens. I'm also not explicitly writing code to call the render method (if that's what you mean) \$\endgroup\$ – Eames Aug 27 '16 at 16:06
  • \$\begingroup\$ Continuous rendering means the render method is called as frequently as the system can manage (e.g quite a lot) and request rendering means you have to explicity write Gdx.graphics.requestRendering(); to call into it \$\endgroup\$ – Huxellberger Aug 27 '16 at 16:11
  • \$\begingroup\$ @Huxellberger Then in that case, I'm using continous rendering \$\endgroup\$ – Eames Aug 27 '16 at 17:26
  • \$\begingroup\$ You might've guessed where I'm going with this. Could be worth giving a switch over to request to see if that improves things. With non-continous rendering you only render at explicit moments you make a call to do so. With your current setup it's possible the render method is flying through at inopportune times. Continuous is also variable on the performance of the device so if you have a dodgy phone that can't keep up it can lead to latent inputs. \$\endgroup\$ – Huxellberger Aug 28 '16 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.