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.