What is the easiest way to draw a dashed line in MonoGame / XNA 4?
Should I use 3d primitives or can I achieve it with a simple sprite?
The user C3 on bitbucket has published a nice utility class to create 2D primitives. These add extension methods to the SpriteBatch class. The repository is here : https://bitbucket.org/C3/2d-xna-primitives/wiki/Home
Welcome
Welcome to the new home of the 2D XNA Primitives project, now using a Mercurial repository on Bitbucket! Now compatible with Windows Phones.
Function Reference
All of the public methods provided by this library are extension methods, which means that you can access them directly through your very own SpriteBatch instance as if these methods were built-in to the SpriteBatch class. If you call the methods in this way, you can ignore the first parameter of all of the following calls.
Public Methods
DrawArc
DrawCircle
DrawLine
DrawRectangle
FillRectangle
PutPixel
If it's a straight line (with simple 90 degree turns) then a sprite is probably the easiest.
(If you've got access to custom shaders via the HiDef profile then achieving dashed lines in shaders isn't too difficult if one keeps one's needs simple)
If it's twisting and turning in an irregular fashion then I would suggest using 3d primitives.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With