关于在菜单中绘制 XNA 上的字符串列表的两个问题。首先是你如何左对齐文本而不是居中对齐呢?其次是你如何在选择任何一个之前显示一个说一行?这是我到目前为止的代码;
public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
{
Color color;
int linePadding = 3;
if (gameTime.TotalGameTime.TotalSeconds <= 3)
{
spriteBatch.Draw(mTheQuantumBros2, new Rectangle(300, 150, mTheQuantumBros2.Width, mTheQuantumBros2.Height), Color.White);
}
else
{
for (int i = 0; i < buttonList.Count; i++)
{
color = (i == selected) ? Color.Gold : Color.LawnGreen;
spriteBatch.DrawString(spriteFont, buttonList[i], new Vector2((screenWidth / 2) - (spriteFont.MeasureString(buttonList[i]).X / 2), (screenHeight / 2) - (spriteFont.LineSpacing * (buttonList.Count) / 2) + ((spriteFont.LineSpacing + linePadding) * i)), color);
}
}
}