Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未捕获SyntaxError:此Javasctript错误的意外标记_Javascript_Keyboard_Syntax Error - Fatal编程技术网

Javascript 未捕获SyntaxError:此Javasctript错误的意外标记

Javascript 未捕获SyntaxError:此Javasctript错误的意外标记,javascript,keyboard,syntax-error,Javascript,Keyboard,Syntax Error,试图为html5游戏创建一个演员类,但我得到了一个未捕获的语法错误。根本不知道这意味着什么,也不知道如何修复它。其他类似的问题通常是关于Jquery的,我找不到任何适合我的问题的解决方案 function Actor(x, y){ //... this.direction = 270; //... } Actor.prototype.update = function(){ if(this.speed >= this.maxspe

试图为html5游戏创建一个演员类,但我得到了一个未捕获的语法错误。根本不知道这意味着什么,也不知道如何修复它。其他类似的问题通常是关于Jquery的,我找不到任何适合我的问题的解决方案

    function Actor(x, y){
//...
        this.direction = 270;
//...
    }


    Actor.prototype.update = function(){
        if(this.speed >= this.maxspeed)
            this.speed = this.maxspeed;

            if(Key.isDown(Key.getCode("a")) this.direction -= 1; // < -- ERROR OCCURS HERE
            if(Key.isDown(Key.getCode("d")) this.direction +=1;
            if(Key.isDown(Key.getCode(" ") this.move();
     }
函数参与者(x,y){
//...
这个方向=270;
//...
}
Actor.prototype.update=函数(){
如果(this.speed>=this.maxspeed)
this.speed=this.maxspeed;
如果(Key.isDown(Key.getCode(“a”))此.direction-=1;//<--此处发生错误
如果(Key.isDown(Key.getCode(“d”))this.direction+=1;
if(Key.isDown(Key.getCode(“”)this.move();
}

所有if语句中都缺少一个右括号。它们应该是

if(Key.isDown(Key.getCode("a"))) this.direction -= 1;
if(Key.isDown(Key.getCode("d"))) this.direction +=1;
if(Key.isDown(Key.getCode(" "))) this.move();

所有if语句中都缺少一个右括号。它们应该是

if(Key.isDown(Key.getCode("a"))) this.direction -= 1;
if(Key.isDown(Key.getCode("d"))) this.direction +=1;
if(Key.isDown(Key.getCode(" "))) this.move();
你有3个开始部分,只有2个结束部分

if(Key.isDown(Key.getCode("a"))) this.direction -= 1;
//                             ^ added
您有多行具有相同问题。请全部更正

你有3个开始部分,只有2个结束部分

if(Key.isDown(Key.getCode("a"))) this.direction -= 1;
//                             ^ added
您有多行具有相同问题。请全部更正