0
我很難看出爲什麼一種方式的作品和方式沒有。switch語句中的if語句?
我有;
switch (key)
{
//If Game over Label is visible, enable the m and e buttons
if(mGameOverLabel->GetVisible())
{
case 'm': case 'M':
ResetScreen();
break;
case 'e': case 'E':
// //Exit the game
Stop();
break;
} else {
case ' ':
mSpaceship->Shoot();
break;
default:
break;
}
對於M和E,即使mGameOverLabel在這個當前時間設置爲false的情況下,我仍然可以按M和E和這些將根據方法反應,但如果我將其更改爲這對M來說,它只會在我需要它的時候才起作用。我在這裏錯過了什麼?
switch (key)
{
//If Game over Label is visible, enable the m and e buttons
case 'm': case 'M':
if(mGameOverLabel->GetVisible()) ResetScreen();
break;
}
在swicth語句之前,你能做到嗎? – Andrew 2012-02-25 17:01:00
@安德魯:什麼? – Ryan 2012-02-25 17:02:23