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\$
5
  • \$\begingroup\$ Are you using continuous rendering or request rendering? \$\endgroup\$ Commented Aug 27, 2016 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
    Commented Aug 27, 2016 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\$ Commented Aug 27, 2016 at 16:11
  • \$\begingroup\$ @Huxellberger Then in that case, I'm using continous rendering \$\endgroup\$
    – Eames
    Commented Aug 27, 2016 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\$ Commented Aug 28, 2016 at 12:37

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.