public int colorMapCollisionDetection(float posx, float posy)
{
Color[] colorMapArray = new Color[1];
colorMap.GetData<Color>(0, new Rectangle((int)posx, (int)posy-25, 1, 1), colorMapArray, 0, 1); //Error happen in this line, and it is so random. i cant figure whats wrong.
Color bgColor = colorMapArray[0];
Color green = new Color(0, 255, 0);
Color red = new Color(255, 0, 0);
if (bgColor == green) {
return 1;
} else if (bgColor == red) {
return 2;
} else {
return 3;
}
}
文字の中心に小さな長方形 (1x1 ピクセル) が作成されます。動くとgetcolordata
風合いが出ます。動作しますが、ランダムにエラーが発生します:
四角形がこのリソースに対して大きすぎるか小さすぎます。パラメータ名:rect.
このエラーの原因は何ですか?