Search code examples
libgdx

TouchDown only seems to fire once in the entire application [libGDX]


So in my game I spawn a grapple hook when I touch the screen, connecting player and ceiling. The problem is that the touchDown() of my inputAdapter only seems to activate the first time I touch, nothing happens after when I touch again (meaning: no other "grapple hooks" get created, just the one). touchUp() or every other input method still work.

Here are all the classes: Rope - GamePlay - InputManager and also just in case MainMenu

EDIT So I was being a moron and in the overlapsOnX() method forgot to add and substract the width of the "cloud" so unless I got very lucky (or spawned in the right place) the rope wouldnt get created.

Here's how the method should look like

private boolean overlapsOnX(Body player, Body cloud){ //check if the player is currently in the same X position than a cloud
    return player.getPosition().x >= cloud.getPosition().x - (20 / PPM) && player.getPosition().x <= cloud.getPosition().x + (20 / PPM);
}

Solution

  • TouchDown returns a boolean to indicate if the input has been processed or not. You are returning false, but you probably mean to return true. This would indicate the input has finished being handled.