Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8175599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:50:19+00:00 2026-06-06T22:50:19+00:00

all. We’re trying to get some intersect collisions working, but the problem experience is

  • 0

all.

We’re trying to get some intersect collisions working, but the problem experience is that the Rectangle does not overlay correcting on the texture.

The texture is a 20×340 pixel image. In the class (Net) for the texture we have a Rectangle to use as the collision box (SetCollisionBox method). We define the following in the Game class (under LoadContent() method).

g_Net = new Net("Net1");
g_scene.Place(g_Net, new Vector3(8, 100, 1));
g_Net.SetCollisionBox(new Rectangle((int)g_Net.Position.X, (int)g_Net.Position.Y, 20, 340));

The problem we have is that the Rectangle is drawn above the texture (the Net) and adjusting the height does make it line up more, but then only the above is collidable with the ball object with a g_Ball.ballRectIntersect(g_Net.netRect). netRect being a public member Rectangle in the Net class and ballRect being the equivalent for the Ball class.

So my question is how can I get the Rectangle overlay to properly appear over the texture so that collision are corresponds with the entire net texture? Is there better way to place this overlay?

Thank you very much in advance.

Cheers.

  • Sam.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T22:50:20+00:00Added an answer on June 6, 2026 at 10:50 pm

    I’m assuming your texture is 2D, since you said Texture and you’re using a Rectangle instead of a BoundingBox.

    In that case, this is very simple to answer.

    To set your collision properties, here’s how you do it. Let’s assume position is our texture position and texture is our loaded texture.

    Rectangle boundingRect = new Rectangle(position.X, position.Y, position.X + texture.Width, position.Y + texture.Height);
    

    Also, if your game is a 2D game, you shouldn’t use a Vector3 to store position unless you’re forced to. Try to use a Vector2, it’ll save you some memory.

    Cheers!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, I have some script tags that are not working in Wordpress. If I
All, I'm using wordpress with this and for some reason the eventDrop stopped working.
all, I am trying to multiply a matrix to a vector in OpenGL, but
All I am trying to create an app that start capturing the video from
All source code hosting services have size limits. I am wondering that does that
All, I'm using the code that facebook provides but here is what I'm using:
All I want to do is return the index of the i that is
All of a sudden, Facebook sharing has stopped working on my site. It's been
All the guys probably will recommend that I read the follow previously question in
All programs that I develop utilize the default Windows Design template: Besides from changing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.