Centring Text Help

I’m quite new to MonoGame/XNA and I’m currently trying to create a pong clone. I’m creating the main menu and I’m trying to get the title of the main menu to centre in the middle of a 800x600 resolution window but it doesn’t seem to centre correctly.

This is my code for creating the title text (I created my own Text object)
title = new Text(font, "Pong", new Vector2(400, 100), Color.White);

An x position of 400 should be in the middle of the window but instead it’s placed like this:

Why is this happening?

The position you specify is the top left corner of your text. You can use SpriteFont.MeasureString to check the length of your text and offset it appropriately so it gets centered.

I tried that but it doesn’t seem to work correctly. It just offsets it way too much

It should work if you just subtract half of what MeasureString gives you from the position vector. Is that what you’re doing?

I hope this contributes here, feedback welcome as I only just woke up and made this before having some tea.


I realise I forgot to mention the entire image represents the display size…