switch语句中的if语句?

r0b*_*077 0 c++ visual-studio-2010 visual-studio

我很难理解为什么一种方式有效而方式无效.

我有;

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;
            }
Run Code Online (Sandbox Code Playgroud)

对于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;
            }   
Run Code Online (Sandbox Code Playgroud)

Sti*_*sis 7

switch基本上没有一个goto到合适的情况标签.上面的任何逻辑case都不会被执行.