繁体   English   中英

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

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

我go这个代码哪里错了? 我做了很多更改,但它似乎一遍又一遍地给出相同的错误:/

    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){}});
        }
    }

该错误表示预期的表达式错误在案例 0 上

似乎无法判断问题出在哪里

它缺少switch语句和花括号 - 也许是复制粘贴错字? 请参阅switch 表达式的文档。

我猜你的 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