我正在尝试使用以下方法绘制七段显示,即使我通过调试器运行,我也看不出原因,但由于某种原因它不显示数字。这里有什么问题?您可以忽略大数组,这只是为了展示我如何存储值。
private void DrawScore(SpriteBatch spriteBatch, int score, int playerNumber)
{
int[,,] numbers =
{
// Zero
// Output:
// [ ][.][ ] [.] = white square [ ] = black square
// [.][ ][.]
// [ ][.][ ]
// [.][ ][.]
// [ ][.][ ]
{
{0, 1, 0},
{1, 0, 1},
{0, 0, 0},
{1, 0, 1},
{0, 1, 0}
},
{
{0, 0, 0},
{0, 0, 1},
{0, 0, 0},
{0, 0, 1},
{0, 0, 0}
},
{
{0, 1, 0},
{0, 0, 1},
{0, 1, 0},
{1, 0, 0},
{0, 1, 0}
},
{
{0, 1, 0},
{0, 0, 1},
{0, 1, 0},
{0, 0, 1},
{0, 1, 0}
},
{
{0, 0, 0},
{1, 0, 1},
{0, 1, 0},
{0, 0, 1},
{0, 0, 0}
},
{
{0, 1, 0},
{1, 0, 0},
{0, 1, 0},
{0, 0, 1},
{0, 1, 0}
},
{
{0, 1, 0},
{1, 0, 0},
{0, 1, 0},
{1, 0, 1},
{0, 1, 0}
},
{
{0, 1, 0},
{0, 0, 1},
{0, 0, 0},
{0, 0, 1},
{0, 0, 0}
},
{
{0, 1, 0},
{1, 0, 1},
{0, 1, 0},
{1, 0, 1},
{0, 1, 0}
},
{
{0, 1, 0},
{1, 0, 1},
{0, 1, 0},
{0, 0, 1},
{0, 0, 0}
}
};
for (int i = 0; i < numbers.GetLength(1); i++)
{
for (int j = 0; j < numbers.GetLength(2); j++)
{
Debug.WriteLine("Score: {0}", score);
Debug.WriteLine("\ti, j: {0}", numbers[score, i, j]);
if (playerNumber == 1)
{
spriteBatch.Draw(numbers[score, i, j] == 0 ? _scoreSegmentTexBlack : _scoreSegmentTexWhite,
new Vector2(
(Graphics.PreferredBackBufferWidth/2) - _scoreSegmentTex.Width*(3 + i),
_scoreSegmentTex.Height*j + 1),
Color.White);
}
if (playerNumber == 2)
{
spriteBatch.Draw(numbers[score, i, j] == 0 ? _scoreSegmentTexBlack : _scoreSegmentTexWhite,
new Vector2(
(Graphics.PreferredBackBufferWidth / 2) + _scoreSegmentTex.Width*(1 + i),
_scoreSegmentTex.Height*j + 1),
Color.White);
}
}
}
}