爆発しそうです。私はこの問題を解決する方法を2時間探していました。setTimerメソッドにswitchステートメントがあります。プログラムをデバッグすると、メソッドの実行中にtimerType値が変更されますが、メソッドが終了するとすぐに、timerTypeはnullに戻ります。これにより、次回メソッドを呼び出すときに変更する必要があるため、caseステートメントは役に立たなくなります。いつものようにシンプルなものだと確信しているので、あなたの助けが大好きです:(。それが文字列タイプか何かに関係があるかどうかを確認するためにintに変更してみました。ちょっとした初心者です。やめてください私はもう悩むことから(少なくともこの特定の問題について:))
public string timerType;
if (checkRoundChanged()) {
SoundPlayer.Play();
setTimer(timerType);
}
と方法
protected void setTimer(String timerType){
switch (timerType) {
case "ready":
secLeft = readySec;
minLeft = readyMin;
timerType = "round";
break;
case "round":
secLeft = roundSec;
minLeft = roundMin;
timerType = "rest";
break;
case "rest":
secLeft = restSec;
minLeft = restMin;
timerType = "round";
break;
case "relax":
secLeft = relaxSec;
minLeft = relaxMin;
timerType = "done";
break;
default:
timerType = "ready";
break;
}
}
ありがとうございました!