여러 구문 변경 후 작동중인 게임에 대해 초기화 된 3D 배열을 얻으려고합니다. 작동 방법을 파악하지 못했습니다! 내가 처음 시작한 것은 :Android 용 배열의 Eclipse보고 오류
public class AnimationView extends SurfaceView implements SurfaceHolder.Callback {//Create bitmaps.
Bitmap bitmapGoal = BitmapFactory.decodeResource(this.getResources(), R.drawable.goal);
Bitmap bitmapOrig = BitmapFactory.decodeResource(this.getResources(), R.drawable.ball);
Bitmap bitmap = Bitmap.createScaledBitmap(bitmapOrig, 150, 150, true);
//initialize the canvas.
private Canvas c;
private int score[] = {0, 0, 0, 0};
public int numBalls = 1;
//we support up to 4 balls. thus each array is 4 bit.
private int ballX[] = {0, 200, 400, 600};
private double ballY[] = {0, 0, 0, 0};
private double dirV[] = {0, 0, 0, 0};
private int dirH[] = {30, 30, 30, 30};
private static final int SCALE = 10;
private double elasticity = .6;
private int rotationNow[] = {5, 5, 5, 5};
private int rotationDraw[] = {0, 0, 0, 0};
class AnimationThread extends Thread {
//Are we running currently?
private boolean mRun;
//layer 1 is how many balls, 4 layers deep.
//layer 2 is which ball we're talking about, either 1, 2, 3, or 4 layers deep, depending on layer 1.
//layer 3 is the bounds of the ball, dependent on how many there are total.
//layer 3 is formatted x-min, x-max, y-min, y-max
int[][][] bounds = new int[][][] {
{ {0, c.getWidth() - bitmap.getWidth(), 0, c.getHeight() - bitmap.getHeight()}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} },
//end first layer
{ {0, c.getWidth()/2 - bitmap.getWidth(), 0, c.getHeight() - bitmap.getHeight()}, {c.getWidth()/2, c.getWidth() - bitmap.getWidth(), 0, c.getHeight() - bitmap.getHeight()}, {0, 0, 0, 0}, {0, 0, 0, 0} },
//end second layer
{ {0, c.getWidth()/3 - bitmap.getWidth(), 0, c.getHeight() - bitmap.getHeight()}, {c.getWidth()/3, c.getWidth() * 2/3 - bitmap.getWidth(), 0, c.getHeight() - bitmap.getHeight()}, {c.getWidth() * 2/3, c.getWidth() - bitmap.getWidth(), 0, c.getHeight() - bitmap.getHeight()}, {0, 0, 0, 0} },
//end third layer
{ {0, c.getWidth()/2, 0, c.getHeight()/2}, {c.getWidth()/2, c.getWidth(), 0, c.getHeight()/2}, {0, c.getWidth()/2, c.getHeight()/2, c.getHeight()}, {c.getWidth()/2, c.getWidth(), c.getHeight()/2, c.getHeight()} }
//end fourth, and final layer!
};
이상한 포맷 오류입니다. 나는 이것이 아무것도 도움이되지 않는다는 것을 안다. ymax와 int [] [] [] 사이에는 새로운 라인이 있습니다. 정확히 살펴보고 이해할 필요는 없지만 컴파일 된 후 실행 중에 오류가 발생합니다. 그럼 나는 간단한 3D 배열을 만들려고, 내가 시작 :
int[][][] bounds = new int[1][1][1];
bounds[0][0][0] = 0;
이클립스는 구불 구불 한 첫 번째 줄에 세미콜론에서 빨간색입니다했다. 말하기 '토큰에 구문 오류가 있습니다. ",이 토큰 다음에 오는 것으로 예상됩니다.
여기가 실망 스럽습니다. 그 정확한 코드 복사/일반 자바 프로그램에 붙여 넣기 잘 작동하기 때문에, 안드로이드 프로젝트 내부에서 작동하도록 얻을 수 없습니다. 나는 다음이에, 몇 가지 물건을 단순화 :
int[] bounds = new int[1];
bounds[0] = 0;
정확한 동일한 오류, 동일한 장소! 왜 이클립스 ?? 나는 또한 "int [] [] [] bounds"와 반대되는 "int bounds [] [] []"로 시도했지만 차이점은 없지만 여전히 같은 오류입니다.
내 컴퓨터를 재부팅하고 프로젝트를 여러 번 청소하고 Eclipse를 다시 시작했습니다. 나는 아이디어가 없어. 당신은 어떤 것을 가지고 있습니까 ??
더 많은 코드를 볼 수 있습니까? (아마도'int [] [] [bounds ...] 앞에 올 것이다.) – MByD
일반적으로 파서는이 줄이 또한 부분이라고 생각하기 때문에이 문장은 닫히지 않은 대괄호 나 누락 된 세미콜론을 넣을 것이다. 그 이전 줄의. – euphoria83
@ euphoria83 내 대답을 참조하십시오. 대개이 문장 다음에 뭔가가 있습니다. – MByD