Note that there are some explanatory texts on larger screens.

plurals
  1. POXNA Draw Method Offsetting unintentionally
    primarykey
    data
    text
    <p>For my current project, I'm trying to include a sprite which simply rotates on the spot. This should be easy, but For some reason, XNA is adding an offset to the position of my sprite.</p> <p>Here is the draw method I'm using:</p> <pre class="lang-cs prettyprint-override"><code>spriteBatch.Draw( texture, //texture2D position, //position Vector2 null, //source Rect (null draws whole texture) Color.White, //Color rotation, //rotation (float) new Vector2(position.X + (texture.Width / 2), position.Y +(texture.Height / 2)), //origin 1f, //scale (float) SpriteEffects.None, //spriteEffects 1); //layer depth </code></pre> <p>position is arbitrary here, currently it is set to be the middle-bottom of the viewport. rotation is an incremental float (increments of 0.1f) and when stepping through the code, the origin point and position both hold the correct values.</p> <p>But no matter what I try, the sprite always gets drawn at some distance from the origin point. It rotates around the origin point, but instead of it being a central axis, the sprite is arching across the screen.</p> <p>I have tried every variant of the XNA 4.0 built-in draw method. Any which mention rotation have this effect. (it is fine with the basic (texture, position, color) method, position-wise. I have also tried changing the texture for something else, honestly I've tried everything I can think of.</p> <p>I'm very appreciative for any help. If a more thorough example is required, I will share it, but honestly there isn't really anything happening outside of this method, which would effect it.</p> <p>Thanks for taking the time to read!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload