Iskalder
Iskalder

Reputation: 41

XNA Item Tooltip

Im creating a rpg like game, I've made a list of items that contains alot of variables like:

I want so that when you over your mouse over an item, a tooltip will appear telling you all the variables of that item, sorta like WoW and all the other rpg games.

I've been thinking about having a rectangle texture that stays on mouse position and will only be shown when mouse over an item.

Now here comes the part where im having problem. I do not know how to scale the texture depending on the amount of text and variable length of that item, so it doesn't look wired. Also is it possible to use some sort of loop that can loop through all my variables and put them under each other?

Cheers!

/Iskalder

Upvotes: 0

Views: 234

Answers (1)

fooser
fooser

Reputation: 852

Are you using a Texture (or Textures) for the text or a font to display the text?

For question 1. If you're using a Texture, you can get the height and width pretty easily and adjust the scale of the tooltip accordingly. If you are using a SpriteFont, you can use SpriteFont.MeasureString to get it's dimensions.

For question 2. As for drawing the items on top of each other, if you are using a SpriteBatch, you can specify how to layer the items in the SpriteBatch.Begin and SpriteBatch.Draw overloads. If you don't mean to layer the variables/items and just want to display them so that they appear "stacked" on top of each other, you can simply specify the origin at which to draw the item in SpriteBatch.Draw and have each subsequent item drawn at a different height (y coordinate).

Upvotes: 1

Related Questions