我有這個switch語句來測試我的接地整型變量的情況,但我的Unity-Monodevelop說我在我的代碼中有奇怪的語法錯誤,我找不到。我希望有人能告訴我它有什麼問題。C#開關語法錯誤
private void JumpController() {
if (Input.GetAxis("Jump")) { // if jump switch to action
switch (Grounded) {
0: // On ground;
Jump();
Grounded = 1;
break;
1: // Jumped once;
Jump();
Grounded = 2;
break;
2: // Jumped twice;
Debug.print ("Grounded = 2");
break;
default: break;
}
}
}
情況下,x:? ...... – StuartLC
您錯過了'case'關鍵字。例如'case 0:Jump();' –