0
\$\begingroup\$

I'm creating some rectangles surrounding my sprites for my player and bullet class to detect collisions with the overlaps method in Intersector class of LibGDX.

I have a question:

When I instantiate Player and Bullet, I create a bounding box around the sprite using sprite.getBoundingRectangle() which returns a Rectangle object. I update the movement of these somewhere else in the main class.

When I update the movement of the bullet/player sprite, do I also need to update the position of the bounding box surrounding the bullet/player sprite? Or since the bounding Rectangle surrounds the sprite, will the box automatically move with the sprite?

Thanks

\$\endgroup\$
1
\$\begingroup\$

The bounding box automatically move with the sprite. If you don't believe it, use the ShapeRenderer to draw your sprite's bounding box each frame and check if it actually follow it or not.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.