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