GetWidth
Introduction
The GetWidth method returns the width of a piece of text. The GetWidth method returns the width of text, and can accept a variety of arguments. The overloads provide flexibility depending on how much information is needed.
Overloads
public static float GetWidth(string text)
public static float GetWidth(string text, float spacing)
public static float GetWidth(string text, float spacing, BitmapFont font)
public static float GetWidth(string text, float spacing, BitmapFont font, int startIndex, int count)
public static float GetWidth(string text, float spacing, BitmapFont font, int startIndex, int count, List<float> widthList)
public static float GetWidth(Text text)Code Example
The following code creates a Text object and a Line which can be moved between letters with the left and right arrows on the keyboard:
Add the following using statements:
Add the following to your Game or Screen's class scope:
Add the following to your Game's Initialize or Screen's CustomInitialize:
Add the following to your Game's Update or Screen's CustomActivity:
Add the following function at class scope:
Last updated
Was this helpful?