Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am really new XNA programming, and i am having a big problem. I have a Vector2, spritePosistion, that controls what position the sprite is at, now i want to move it by 1, every time that a player hits the w button, it is having a problem 1 being and int and spritePosistion being a Vector2. So am i doing it wrong or is there a way of getting these things to work together. Here is the code

if (Keyboard.GetState().IsKeyDown(Keys.W))
    // This is the problem 
    spritePosition += 1;
share|improve this question
You need to study vectors. – doppelgreener May 12 '12 at 22:01

It depends, you're being awfully vague in your question. For instance, in which direction do you want to move? A few examples...

  • Right spritePosition.X += 1

  • Left spritePosition.X -= 1

  • Down spritePosition.Y += 1

  • Up spritePosition.Y -= 1

share|improve this answer

You said you want to "move the sprite by one" - but in which direction? Try

spritePosition.X += 1;


spritePosition.Y += 1;

for X or Y movement.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.