2

我不断收到一个错误,它在“案例'captain-cool'”中期待一个},我不知道这意味着什么,添加一个}给了我同样的错误。

swith(curSong.toLowerCase());
        {
            case 'captain-cool':
            {
                trace('matthewanimation')
                inCutscene = true;

                var matthewMicGrab:FlxSprite = new FlxSprite();
                var micsound:FlxSound = new FlxSound().loadEmbedded('assets/week1/sounds/micsound.ogg')
                var armmove:FlxSound = new FlxSound().loadEmbedded('assets/week1/sounds/armmove.ogg')
                matthewMicGrab.frames = Paths.getSparrowAtlas('assets/week1/images/cutsceneshit/matthewMic.png','assets/week1/images/cutsceneshit/matthewMic.xml');
                matthewMicGrab.animation.addByPrefix('micgrab', 'Matthew MIC', 24, false);
                animation.antialiasing = true;
                add(animation);
4

1 回答 1

1

case语句后不需要大括号,switch也不是函数。

这是正确语法的演示:

switch (curSong.toLowerCase()) {
    case 'captain-cool':
        trace('matthewanimation');
    case 'something-else':
        doStuff();
    default:
        doDefaultThings();
}
于 2021-03-27T23:24:07.760 回答