即時通訊新的android工作室,我想這個函數循環,並創建一個無限的球落環將被評分,直到兩個整數不匹配,但是當我嘗試運行它,它只會循環一次,如果我在else
語句更改streak = 2
應用程序崩潰我如何組織這個功能,所以它的作品,我打算它
public void mainGameLoop(){
do {
//sets Balls integer
setColourint();
ball.setVisibility(View.VISIBLE);
//ball fall
float bottomOfScreen = getResources().getDisplayMetrics()
.heightPixels - (ball.getHeight() * 4);
//fall animation
ball.animate()
.translationY(bottomOfScreen)
.setInterpolator(new AccelerateInterpolator())
.setInterpolator(new BounceInterpolator())
.setDuration(9000);
//once animation is complete compares balls variable with current variable
if (colourint == ranint){
//if they are same then +1 score
score = score+1;
scr.setText(Integer.parseInt(String.valueOf(score)));
} else {
//else game is over
streak = 2;
}
//repeat until game is over
} while (streak == 1);
}
一旦球達到相對佈局我想要的功能檢查的底部,如果setcoulour int
和ran int
是相同的,然後如果是score = score + 1
,球回到頂部,setColourInt
函數被調用並且球再次落下(等等等等),但如果不是循環結束,它的遊戲結束了......我爲我公然的無能而道歉,但我無法想象你們也不記得你們什麼時候也是,在編碼時這是天真的。非常感謝湯姆
現在你認爲「錯了」是什麼? – markspace