I am looking for a collision detection solution for use when 2d screen wrapping. Specifically, when the image is split between the right and left side I can only detect a collision for a limited area.
For example, the program detects the collision when the rectangle intersects the circle in the first image. However, it doesn't in the second image. I am using the Rectangle.Instersects method to check for the collision in both cases.
I used the screen-wrapping solution at the following link: How to create a 2D region where sprites are automatically wrapped?
However, since I am not using the physics engine, I am not using the related solution at: How to create a very specific kind of joint in Farseer?
I am aware of the following question: https://stackoverflow.com/questions/8679304/wrapping-drawn-image-in-xna-4-0, and incorporated part of the code to reset the draw rectangle's position when wrapping for both sprites:
// reset draw rectangle for wrapping
if (drawRectangle.X < -sprite.Width)
{
drawRectangle.X += parentWindowWidth;
}
if (drawRectangle.X > parentWindowWidth)
{
drawRectangle.X -= parentWindowWidth;
}
if (drawRectangle.Y < -sprite.Height)
{
drawRectangle.Y += parentWindowHeight;
}
if (drawRectangle.Y > parentWindowHeight)
{
drawRectangle.Y -= parentWindowHeight;
}
This post also says that I have to check for the collision in the two separate positions, but I am having trouble doing so.
Any suggestions?