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

  • SEARCH
  • Home
  • 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 7777053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:02:32+00:00 2026-06-01T18:02:32+00:00

Hello Stack Overflow users, I have a fun problem that I have in my

  • 0

Hello Stack Overflow users, I have a fun problem that I have in my XNA Game.

So basically I have an asteroid, 80×80, and I set the origin as imageW / 2, imageH / 2 (If order would matter, it wouldn’t, the asteroid is a square).

Here is an image, explaining the problem! Visualization FTW 😀

https://i.stack.imgur.com/9ymeg.png

So, any ideas on what is causing this? I spend 1 hour, I looked at examples, I found out it is supposed to rotate like this:

http://www.riemers.net/images/Tutorials/XNA/Csharp/Series2D/rotation.jpg

But it’s not.

Here is a code sample. I have a object named Drawable that has properties which hold the vector position, etc.

Vector2 asteroidOrigin = new Vector2(asteroidImgs[asteroid.asteroidType].Width / 2, asteroidImgs[asteroid.asteroidType].Height / 2);

drawableList.Add(new Drawable(asteroidImgs[asteroid.asteroidType], asteroid.asteroidPos, asteroid.angle, asteroidOrigin));

Here is the Draw Method:

foreach (Drawable drawable in renderManager.getRenderList)
        {
            spriteBatch.Draw(drawable.image, drawable.position, drawable.sourceRectangle, drawable.tint, drawable.angle, drawable.origin, drawable.imageScale, drawable.spriteEffects, drawable.depth);
        }

And yes, the Drawable Class has multiple constructors and they assign default values.

  • 1 1 Answer
  • 1 View
  • 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-01T18:02:33+00:00Added an answer on June 1, 2026 at 6:02 pm

    When you define an Origin in SpriteBatch.Draw, you are defining the new point on your texture which will draw at the Position argument. Obviously this affects translation as well as your desired rotation. When you set the origin to the center of the image, the image is translated so that the center is at your Position, then rotated around that point. When you set the origin to Vector2.Zero, the translation is not changed, but the image rotates around its top left corner.

    The solution is to either redefine what you mean as “Position” for sprites to be where the CENTER of the image draws on screen (I recommend this, makes things nice) or perform a bit of work before drawing by adding the Origin to the Position before calling Draw.

    I, again, recommend the first solution, because then when you want to draw a circle in the center of the screen you can just set its position to be the center of the screen and be done. You won’t need to take its size into account. And so on.

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

Sidebar

Related Questions

Hello good Stack Overflow people, I do have a business problem and would like
Hello Stack Overflow i hope you are well today; I have a form that
Hello stack overflow I need help with this problem. Ok, I have a flat
Hello people of stackoverflow. I have a problem. I'm trying to set up my
Hello Stack Overflow i hope you are well today, I have this code: $('.add_child').click(function(){
Hello Stack Overflow Experts, i have need of your expertice: I am trying to
I know many people have had this problem and I have searched Google/Stack Overflow,
Hello StackOverflow Users, I am new to android and trying to develop a game
Hello there Stack Overflow, I hope you'll help me with my very first question
First off - hello, this is my first Stack Overflow question so I'll try

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.