2
내 프로그램은 슬라이딩 퍼즐 게임으로 디자인되었습니다. 나는 현재 보드에서 플레이어가 해결할 수 있도록 타일을 일정 시간 이동하기 위해 난수를 사용하는 셔플 버튼을 작업 중입니다.android 응용 프로그램에 과부하가 있습니까?
현재 셔플 버튼을 누르면 발생하는 '활동 방법을 실행할 수 없습니다'라는 오류 메시지가 표시됩니다. while 루프 외부에있을 때 버튼을 계속 누르고있을 수 있었지만 각 클릭 사이에 일정 시간을 두어야했습니다. 임 생각 메신저 프로그램의
public void shuffleTiles(View v){ //Shuffles the tiles using random numbers
int tileToMove;
while (computerMoves < 5){
tileToMove = randomNumbers.nextInt(12);
moveTile(tileToMove, false);
}
주요 요점은 타일 것을 보여주기 위해 이미지를 스왑이 방법을 주위에 일입니다 ... 어떤 방법 프로그램을 오버로드 ...하지만 부하를 줄이는 방법하지 않도록 메신저 이사 :
private void moveTile(int button, boolean playerMove) { //The main method which causes a tile to be moved
int tileToReplace = movePossibleTest(button); //Run the test to see if there is a blank square next to it
if (tileToReplace != 0){
Drawable originalImage = buttons[button-1].getDrawable(); //Saves a drawable of the original image
Drawable blankImage = buttons[tileToReplace-1].getDrawable(); //Saves a drawable of the blank tile
buttons[button-1].setImageDrawable(blankImage); //Swaps the images
buttons[button-1].setTag("blank");
buttons[tileToReplace-1].setImageDrawable(originalImage); //Swaps the tags that identify which is the blank tag
buttons[tileToReplace-1].setTag(null);
if (playerMove){ //If the move was initiated by a player click
moveCount(true);
}
else moveCount(false);
}
}
나는 당신이 UI 쓰레드로 while 루프를 사용해야한다고 생각하지 않는다. 정말로 메모리를 많이 소비한다. 사실, 왜 내가 처음에 while 루프를 사용하는지 알지 못합니다. –
타일로 섞기 위해이 도구를 사용하고 있습니다. 그러나 이제는 그것에 대해 생각해 봅니다. 실제로 프로세스의 UI를 변경하지 않고 실행 한 다음 모든 타일을 계산 된 위치로 바꾸면 과부하가 걸릴 수 있습니까? – Benny292
computerMoves를 조작하고있는 것은 무엇입니까? –