Using C# and the XNA Framework, what is the difference between the "position" and "origin" arguments when calling the SpriteBatch.DrawString method?
The origin is an offset related to the position.
Position is related with the upper left corner of the string.
If you want to rotate your string, it will rotate about that corner, but if you want to rotate about the center of the string in the given position, you have to set the origin as the half size of the string.
Also it lets you rotate about an arbitrary point, doing the right math with origin.
If you want align centered your string, you have to set origin as the half size of the string, and the string will be centered in the position.
If you want align right your string, your origin has to be set to the size of the string.
A little old, but I thought it would be helpful for others that come across this thread while searching for this topic. This confused me as well so I put this image together to help me out...
.
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