この次の方法を使用して 7 セグメント表示を描画しようとしていますが、デバッガーを実行しても理由がわかりませんが、何らかの理由で数字が表示されません。ここで何が問題なのですか?大きな配列は無視してかまいません。これは、値を格納する方法を示すためのものです。
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);
}
}
}
}