나는 이것에 대해 도움이 필요합니다. 기본적으로 2 명의 플레이어와 함께 타이머를 사용하는 미니 게임을 만들려고합니다. 그것은 계속해서 각 사용자에 대해 가장 높은 점수를 얻고 점수를 저장 한 3 라운드가 끝날 때 저장합니다. 나는 이것을 play == 2로했을 때 else 내 모든 것을 둘러싼 루프를 시도했다. 첫 번째 클릭시 승자가 자동으로 표시됩니다. 이 섹션의 코드는 다음과 같습니다. 버튼이 같은 XML/클래스로 연결된 2 개 개의 게임을 가지고 있기 때문에 플레이 == 2가있는 경우내 게임은 승자를 표시하지 않습니다.
else if (play==2)
{
round++;
turn = turn%2;
if (turn == 0 && turn<3)
{
TextView c1c = (TextView) findViewById(R.id.player);
c1c.setText(" CHALLENGER 1:");
click=click%2;
if (click==0 && turn<6)
{
reset();
TextView challenger1 = (TextView) findViewById(R.id.display);
challenger1.setText("");
start();
click++;
startbutton.setText("Stop");
}
else if (click==1 && turn < 6)
{
stop();
getElapsedTimeMicro();
TextView time1 = (TextView) findViewById(R.id.display);
time1.setText(" "+ formatter.format(elapsed));
if (elapsed > c1time)
c1time=elapsed;
click++;
startbutton.setText("Start");
turn++;
}
}
else if (turn ==1 && turn < 3)
{
TextView c2 = (TextView) findViewById(R.id.player);
c2.setText(" CHALLENGER 2:");
click=click%2;
if (click==0)
{
reset();
TextView challenger2 = (TextView) findViewById(R.id.display);
challenger2.setText("");
start();
click++;
startbutton.setText("Stop");
}
else if (click==1)
{
stop();
getElapsedTimeMicro();
TextView time2 = (TextView) findViewById(R.id.display);
time2.setText(" "+ formatter.format(elapsed));
if (elapsed>c2time)
c2time=elapsed;
click++;
startbutton.setText("Start");
turn++;
}
}
if (round==3)
{
if (c1time > c2time)
{
TextView winner1 = (TextView) findViewById(R.id.display);
winner1.setText("Challenger 1 is the Iron Lung!\n"+formatter.format(c1time));
}
else if (c2time > c1time)
{
TextView winner2 = (TextView) findViewById(R.id.display);
winner2.setText("Challenger 2 is the Iron Lung!\n"+formatter.format(c2time));
}
click=0;
turn=0;
c1time=0;
c2time=0;
}
}
이 모든 것은 내가 원인하지만 문제의 원인이라고 생각 글꼴 ... 버튼합니다 (다른 내 다른 게임은 잘 작동합니다.)이 게임은 플레이어가 올바르게 바뀌 었음을 올바르게 표시합니다. 문제가 끝나야 할 때 발생합니다. 나는이 모든 것을 고치기 위해 elses를 사용했다면 시도했다. 도움을 좀 줘. 감사. 당신이 뭘 하려는지
gamedev.stackexchange.com – Nate
질문 7 건의 답변을 수락 할 수 있습니까? 행운을 빕니다 ... –