【问题标题】:HaxeFlixel - Expected } error when using a case commandHaxeFlixel - 使用 case 命令时出现预期的 } 错误
【发布时间】:2021-06-24 10:03:43
【问题描述】:

我一直收到一个错误,在“case '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);

【问题讨论】:

  • 错误具体是“Playstate.hx:830: characters 4-8 : Expected }”

标签: haxe haxeflixel haxelib


【解决方案1】:

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

这是正确语法的演示:

switch (curSong.toLowerCase()) {
    case 'captain-cool':
        trace('matthewanimation');
    case 'something-else':
        doStuff();
    default:
        doDefaultThings();
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-05
    • 1970-01-01
    • 2022-01-18
    • 2021-03-10
    • 2016-09-13
    • 2014-03-18
    • 2016-05-29
    • 1970-01-01
    相关资源
    最近更新 更多