Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

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

initially image placed (0,0)th position and where ever i touch that is end position.

Now i got Start Position(0,0) and End Position(200,200).

i want to move start to end vector using angle.

If anyone now the ans please tell me.

share|improve this question
-1 It is not clear at all what you're asking. Do you want to draw a line or determine the angle of the vector or something else? – doppelgreener Apr 17 '12 at 5:19
i want to move image using two vector points/rectangle points. – Ramachandran Apr 17 '12 at 5:22
So what do the two points have to do with it? Are you resizing the image, are you moving it to point B, or what? – doppelgreener Apr 17 '12 at 5:23
i want to move image A position to B position with angle – Ramachandran Apr 17 '12 at 5:29
Possible duplicate:… – Roy T. Apr 17 '12 at 5:52

You need to find the delta between your two vectors and just move the sprite along that new vector.

Vector2 startPos = new Vector2(0,0);
Vector2 endPos = new Vector2(100,200);

Vector2 delta = endPos - startPos;

//see if he is at the target. Very rarely will it be Vector2.Zero, so subtract 3 to get you close. If you don't do this your sprite can bounce.
if ((delta.X > -3 && delta.X < 3)
  && (delta.Y > -3 && delta.Y < 3))
    sprite.Moving= false;

    delta.Normalize() //you want to normalize the vector. Otherwise he will move faster diagnoally

    sprite.Position += delta *5f;  //5f is a random speed I chose. The higher this number, the faster he will move
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.