libgdx collision detection / bounding the object

Posted by johnny-b on Game Development See other posts from Game Development or by johnny-b
Published on 2014-06-09T00:43:12Z Indexed on 2014/06/09 3:44 UTC
Read the original article Hit count: 267

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?Huh 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();

thank you

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

© Game Development or respective owner

Related posts about java

Related posts about android