简体   繁体   English

编译时如何修复案例中的预期错误

[英]how do i fix expected error on a case when compiling

Where did I go wrong with this code?我go这个代码哪里错了? I've done lots of changes but it just seems to give the same error all over and over again:/我做了很多更改,但它似乎一遍又一遍地给出相同的错误:/

    function changeDifficulty(change:Int = 0):Void
     
            case 0:
                easy.loadGraphic(Paths.image('storymenu/easyglow'));
                normal.loadGraphic(Paths.image('storymenu/normal'));
                hard.loadGraphic(Paths.image('storymenu/hard'));
                FlxTween.tween(easy,{y: 286},0.1,{ease: FlxEase.expoInOut, onComplete: function(flxTween:FlxTween){}});
                FlxTween.tween(normal,{y: 266},0.1,{ease: FlxEase.expoInOut, onComplete: function(flxTween:FlxTween){}});
                FlxTween.tween(hard,{y: 266},0.1,{ease: FlxEase.expoInOut, onComplete: function(flxTween:FlxTween){}});
            case 1:
                easy.loadGraphic(Paths.image('storymenu/easy'));
                normal.loadGraphic(Paths.image('storymenu/normalglow'));
                hard.loadGraphic(Paths.image('storymenu/hard'));
                FlxTween.tween(easy,{y: 266},0.1,{ease: FlxEase.expoInOut, onComplete: function(flxTween:FlxTween){}});
                FlxTween.tween(normal,{y: 286},0.1,{ease: FlxEase.expoInOut, onComplete: function(flxTween:FlxTween){}});
                FlxTween.tween(hard,{y: 266},0.1,{ease: FlxEase.expoInOut, onComplete: function(flxTween:FlxTween){}});
            case 2:
                easy.loadGraphic(Paths.image('storymenu/easy'));
                normal.loadGraphic(Paths.image('storymenu/normal'));
                hard.loadGraphic(Paths.image('storymenu/hardglow'));
                FlxTween.tween(easy,{y: 266},0.1,{ease: FlxEase.expoInOut, onComplete: function(flxTween:FlxTween){}});
                FlxTween.tween(normal,{y: 266},0.1,{ease: FlxEase.expoInOut, onComplete: function(flxTween:FlxTween){}});
                FlxTween.tween(hard,{y: 286},0.1,{ease: FlxEase.expoInOut, onComplete: function(flxTween:FlxTween){}});
        }
    }

The error said the expected expression error was on the case 0该错误表示预期的表达式错误在案例 0 上

Can't seem to tell where is the problem似乎无法判断问题出在哪里

It is missing the switch statement and curly braces - maybe a copy-paste typo?它缺少switch语句和花括号 - 也许是复制粘贴错字? See the docs for the switch expression .请参阅switch 表达式的文档。

I'm guessing the top of your function should look something like:我猜你的 function 的顶部应该是这个样子:

function changeDifficulty(change:Int = 0):Void { 
     switch change {
            case 0:
            // ...snip...
     }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM