Search code examples
libgdx

LibGdx - Increase touch-area of Actor


Is there a way for me to increase the touch-area of an Actor in LibGdx? In my case its a Label, I don't want to use a large button but its really hard to press the Label on the phone, so can I increase the touch area around the Label?


Solution

  • You should be able to modify the labels boundry.

    Try the following method from the Actor class:

    setBounds( float x, float y, float width, float height )
    

    To dynamically set the boundry, you might be able to do something like:

    float padding = 5f;
    label.setBounds(label.getX() - padding, label.getY() - padding,
        label.getWidth() + (padding * 2f), label.getHeight() + (padding * 2f));