2D Line (XNA)
-
Hello. It may seem like a beginner question, but I'd like to know how to draw a line. Simple? I've been looking all over the net, and through these books I have, (also CodeProject) and nothing "works". Please help, thanks in advance.
- I love D-flat!
-
Hello. It may seem like a beginner question, but I'd like to know how to draw a line. Simple? I've been looking all over the net, and through these books I have, (also CodeProject) and nothing "works". Please help, thanks in advance.
- I love D-flat!
Hi, for the Form, Panel, or whatever Control you want to draw on, use the OnPaint handler (or add a new handler to the Paint event); it will give you a PaintEventArgs offering a Graphics object, then use Graphics.DrawLine() and the like. If you need examples, there are plenty around at CP. My Sokoban article also has some line drawing. [ADDED] just noticed some essential info got hidden in the subject line; for XNA things are a bit more complicated, but they do provide some documentation, so this may help[^]. [/ADDED] :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
modified on Sunday, January 13, 2008 5:03:32 PM
-
Hi, for the Form, Panel, or whatever Control you want to draw on, use the OnPaint handler (or add a new handler to the Paint event); it will give you a PaintEventArgs offering a Graphics object, then use Graphics.DrawLine() and the like. If you need examples, there are plenty around at CP. My Sokoban article also has some line drawing. [ADDED] just noticed some essential info got hidden in the subject line; for XNA things are a bit more complicated, but they do provide some documentation, so this may help[^]. [/ADDED] :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
modified on Sunday, January 13, 2008 5:03:32 PM
Oh, I know how to draw lines there. That's easy. BUT, in XNA, it's a whole new territory. To your added reply, I've seen that, and tried, but wasn't sure what type the variables were when previously declared (they didn't show it there). Example: points? (My bad, I had pointList; it was points)
- I love D-flat!
modified on Sunday, January 13, 2008 5:10:42 PM