Javascript 未捕获SyntaxError:此Javasctript错误的意外标记
试图为html5游戏创建一个演员类,但我得到了一个未捕获的语法错误。根本不知道这意味着什么,也不知道如何修复它。其他类似的问题通常是关于Jquery的,我找不到任何适合我的问题的解决方案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
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
您有多行具有相同问题。请全部更正