Original Post
I am trying to render a sprite on the screen that will not move but only rotate.
I want to make it so when you press the 'A' key it rotates counterclockwise and if you press the 'D' key it rotates clockwise
I am very new to XNA so i know my code isnt the best atm i tend to make 1 small program and add to it piece by piece so when i go through these learning programs they tend to not be as clean as they can be.
in my draw method when i make the uncommented call it draws my arrow fine ... no rotation but everything is drawn at the correct spots.
when i draw using the commented part the arrow is in a completely different position and it pivots more than it rotates. can anyone help me at all?
Thanks in advance
I want to make it so when you press the 'A' key it rotates counterclockwise and if you press the 'D' key it rotates clockwise
I am very new to XNA so i know my code isnt the best atm i tend to make 1 small program and add to it piece by piece so when i go through these learning programs they tend to not be as clean as they can be.
class GameObject
{
public Vector2 position;
public Rectangle rect;
public Texture2D image;
public float rotation;
public Vector2 origin;
public GameObject()
{
position = new Vector2(300, 300);
rect = new Rectangle(300, 300, 64, 64);
rotation = 0.0f;
origin.X = position.X + (rect.Width / 2);
origin.Y = position.Y + (rect.Height / 2);
}
public void loadContent(ContentManager manager)
{
image = manager.Load<Texture2D>("up");
}
public void draw(SpriteBatch batch)
{
batch.Draw(image, position, Color.White);
//batch.Draw(image, rect, null, Color.White, rotation, origin, SpriteEffects.None, 0f);
}
public void update(KeyboardState k_state)
{
if (k_state.IsKeyDown(Keys.A))
{
rotation -= 0.1f;
}
if (k_state.IsKeyDown(Keys.D))
{
rotation += 0.1f;
}
}
}
in my draw method when i make the uncommented call it draws my arrow fine ... no rotation but everything is drawn at the correct spots.
when i draw using the commented part the arrow is in a completely different position and it pivots more than it rotates. can anyone help me at all?
Thanks in advance