액세스하는 동안오류 배열
[] 안에 인덱스틀린 번호; 예상치 2
코드 하단 부근. 이유가 확실하지 않습니다. 조작 할 배열 집합을 만들려고하지만이 시점에서 끊깁니다.
public static void Main (string[] args)
{
Initialize();
while (true) {
SystemEvents.CheckEvents();
Update();
Render();
}
}
public static void Initialize()
{
// Set up the graphics system
graphics = new GraphicsContext();
gen = new Random();
Texture2D pTex= new Texture2D("Application/assets/plane.png",false);
player= new Sprite(graphics,pTex);
player.Position.X = graphics.Screen.Rectangle.Width/2 - player.Width/2;
player.Position.Y = graphics.Screen.Rectangle.Height/2 - player.Height/2;
xpos = 0;
ypos = 0;
pieces = new Texture2D[6];
bg = new Sprite[9,12];
pattern = new int[9,12];
for (int i=0; i<6; i++)
pieces [i] = new Texture2D ("Application/assets/island" + i + ".png", false);
for(int i=0; i< pattern.Length; i++)
pattern[i] = gen.Next(0,5); // Problem is here
새로운 int [9,12] => 테이블에 9 개의 행과 열 12가있는 2 차원 배열을 만듭니다. –
@AjayTakur : 그것이 무엇입니까. 그러나 그것이 OP가 생각하는 것만 큼 명확하지 않습니다. –
예. 불량 복사 및 붙여 넣기 작업을해서 죄송합니다. 여기에 대한 첫 번째 게시물이고 프로그래밍에 익숙하지 않습니다. 예, 9 행 12 열의 배열을 만드는 이해합니다. 내가 모르는 것은 왜 그것이 나에게 잘못된 숫자의 지표 오류를 줄 수 있는지입니다. – Marcw424