我很难理解为什么有一种方法可以工作,而另一种方法不能。
我有;
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;
} 发布于 2012-02-26 01:01:29
switch基本上对适当的case标签执行goto。将不会执行case之上的任何逻辑。
https://stackoverflow.com/questions/9446053
复制相似问题