Question

I'm currently working on an RPG game using the XNA Framework.

Currently, when determining where text is displayed on the screen, I'm using trial and error method to find Y co-ordinates, i.e. loading up and then modifying the coordinate to alter the position.

The code sample below shows how I am processing the "Conversation" text

titleString = Fonts.SplitTextIntoLines(Conversation.CurrentNode.Text, Fonts.Font, new Vector2(maxWidth, 0));
titlePosition.X = (viewport.Width - Fonts.Font.MeasureString(titleString).X) / 2;
titlePosition.Y = backgroundPosition.Y + 200f;

Fonts.SplitTextIntoLines splits the input up into multiple lines depending on the Font used and the max width specified, this is irrelevant for my question

titlePosition.X: here I am centering the text on the screen

titlePosition.Y: This is the line I am bothered by

If there was some kind of tool which would allow me to have a blank window which I could position a piece of text, or image on and then see the coordinates, it would be a massive help.

If anyone knows of a tool like this, could you let me know? :)

Here is a screenshot to illustrate my question better http://img836.imageshack.us/img836/1929/i86g.png

Was it helpful?

Solution

The easy answer would be for you to implement a very basic tool to help to position your objects in your scene. Most game engine will have an editor for you to do so but since XNA is just a framework, you could implement a very simple system with your keyboard and arrow to move your text around and output on screen the X and Y position. It's not perfect but it should save you some time.

Also:

Vector2 mousePosition = new Vector2(Mouse.GetState().X,Mouse.GetState().Y);

Console.WriteLine("My Cursor is at: " + mousePosition);

Don't forget the IsMouseVisible member of Game to be able to actually see your mouse cursor.

Hope it helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top