admin管理员组文章数量:1355570
Trying to create an actor class for an html5 game, but I get an Uncaught SyntaxError. Not sure at all what it means or how to fix it. Other questions like this are usually about Jquery and I couldn't find any solutions that fit my problem.
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();
}
Trying to create an actor class for an html5 game, but I get an Uncaught SyntaxError. Not sure at all what it means or how to fix it. Other questions like this are usually about Jquery and I couldn't find any solutions that fit my problem.
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();
}
Share
Improve this question
asked Aug 13, 2013 at 21:46
jatmdmjatmdm
751 gold badge1 silver badge5 bronze badges
2 Answers
Reset to default 4You're missing a closing parentheses in all your if statements. They should be
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(Key.isDown(Key.getCode("a")) this.direction -= 1;
You have 3 opening parens, and only 2 closing ones.
if(Key.isDown(Key.getCode("a"))) this.direction -= 1;
// ^ added
You have multiple lines with this same problem. Correct them all.
本文标签: javascriptUncaught SyntaxError Unexpected token this Javasctript ErrorStack Overflow
版权声明:本文标题:javascript - Uncaught SyntaxError: Unexpected token this Javasctript Error - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743970677a2570674.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论