Saturday, May 25, 2013

Draw 2dline Using XNA 4.0

Draw 2dline Using XNA 4.0

how to draw line using XNA 4.0 from Touch gestures
public void DrawLine(SpriteBatch sb, Vector2 start, Vector2 end, Texture2D texture) {
        Vector2 NStart=new Vector2(20, 20);
        Vector2 NEnd = new Vector2(120, 120);
        Rectangle rec = new Rectangle((int)NStart.X, (int)NStart.Y, 10, 10);
        Vector2 edge = NStart - NStart;



        spriteBatch.Begin();

        texture = Content.Load<Texture2D>("Blue");

        spriteBatch.Draw(texture, NStart, null, Color.Black,
                     (float)Math.Atan2(NEnd.Y - NStart.Y, NEnd.X - NStart.X),
                     NStart,
                     NEnd,
                     SpriteEffects.None, 0);





        spriteBatch.End();


    }

No comments:

Post a Comment