libgdx collision detection / getting bounds

i am trying to get collision detection so i am drawing a red rectangle to see if it is working, and when i do the code below in the update method. to check if it is going to work. the position is not in the right place. the red rectangle starts from the middle and not at the x and y point???
so it draws it wrong.
i also have a getter method so nothing wrong there.


		bullet.set(getX(), getY(), getOriginX(), getOriginY());

this is for the render


                shapeRenderer.begin(ShapeType.Filled);
		shapeRenderer.setColor(Color.RED);
		shapeRenderer.rect(bullet.getX(), bullet.getY(), bullet.getOriginX(), bullet.getOriginY(), 15, 5, bullet.getRotation());
                shapeRenderer.end();

i have tried to do it with a circle but the circle draws in the middle and i want it to be at the tip of the bullet. at the front of the bullet. x, y point.


        boundingCircle.set(getX() + getOriginX(), getY() + getOriginY(), 4.0f);


shapeRenderer.begin(ShapeType.Filled);
shapeRenderer.setColor(Color.RED);
shapeRenderer.circle(bullet.getBoundingCircle().x, bullet.getBoundingCircle().y, bullet.getBoundingCircle().radius);
shapeRenderer.end();

johnny

need it to be of the x and y as the bullet is in the middle of the sprite when drawn originally via paint.

To change the origin of your bounds, you can add the width/height of the rectangle, or subtract.

If the origin of the rectangle is bottom left but you need it positioned from the centre, you would do:

rect.x + (width / 2), rect.y + (height / 2)

This will take the x coordinate, add the half width on which puts the x value at a midpoint along the rect.

Play around with this to fit your code.

thanks alot mate
it is working to a point just trying to adjust like you said.

the hardest is the circle.

i just want the front of the bullet to do the collision test so i can save time and maybe take less memory.