This is my first attempt in game development. I just started experimenting libgdx and understanding the different aspects of game programming. I looked at the sample project
public static boolean pointInRectangle (Rectangle r, float x, float y) {
return r.x <= x && r.x + r.width >= x && r.y <= y && r.y + r.height >= y;
}
In your update-
if(pointInRectangle(flyRectangle, Gdx.input.getX(), Gdx.input.getY())){
// Do whatever you want to do with the rectangle. maybe register them for effect
}
You can also look into Intersector class.
Now for collision, if your game is fast-paced, with lots of enemies moving around that the player can collide with, sooner or later you will use a box2d type library because if the movement speed is high, you might not get any collision callback. Things might go through each other. You can try predicting the collision before it happens using the velocity and deltaTime, but it's still not going to be enough and you will end up reinventing the wheel.
Mario's SuperJumper is a great demo to start libGDX. Try it.
EDIT:
Have an instance member-
Vector3 touchPoint;
On create-
touchPoint = new Vector3();
On update-
camera.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));
if (Gdx.input.justTouched()) {
if (pointInRectangle(rectangle, touchPoint.x, touchPoint.y)) {
}
}
Please take note of the coordinate system in libGDX. For testing, create one rectangle on screen. On click, print/debug the coordinates of both the rectangle and touchPoint.