protected void processTouchPressed() { final float x = MathUtils.bringToBounds(0, baseWidth, Touch.getX() - getScreenX()) / baseWidth - 0.5f; final float y = MathUtils.bringToBounds(0, baseHeight, Touch.getY() - getScreenY()) / baseHeight - 0.5f; if (x == 0 && y == 0) { return; } if (MathUtils.abs(x) > MathUtils.abs(y)) { if (x > 0) { this.isRight = true; this.isClick = true; this.centerX = offsetX + x + (baseWidth - dotWidth) / 2 + dotWidth * 0.75f; this.centerY = offsetY + y + (baseHeight - dotHeight) / 2; if (listener != null) { listener.right(); } } else if (x < 0) { this.isLeft = true; this.isClick = true; this.centerX = offsetX + x + (baseWidth - dotWidth) / 2 - dotWidth * 0.75f; this.centerY = offsetY + y + (baseHeight - dotHeight) / 2; if (listener != null) { listener.left(); } } else if (x == 0) { freeClick(); } } else { if (y > 0) { this.isDown = true; this.isClick = true; this.centerX = offsetX + x + (baseWidth - dotWidth) / 2 - 1; this.centerY = offsetY + y + (baseHeight - dotHeight) / 2 + dotHeight * 0.75f; if (listener != null) { listener.down(); } } else if (y < 0) { this.isUp = true; this.isClick = true; this.centerX = offsetX + x + (baseWidth - dotWidth) / 2 - 1; this.centerY = offsetY + y + (baseHeight - dotHeight) / 2 - dotHeight * 0.75f; if (listener != null) { listener.up(); } } else if (y == 0) { freeClick(); } } }