2013-08-13 4 views
-1

html5 게임에 대한 액터 클래스를 만들려고했지만 Uncaught SyntaxError가 발생합니다. 그것이 의미하는 것이나 그것을 고치는 법을 전혀 모릅니다. 이와 같은 다른 질문은 대개 Jquery에 관한 것이므로 내 문제에 맞는 솔루션을 찾을 수 없습니다.잡히지 않은 SyntaxError : 예기치 않은 토큰이 Javasctript 오류

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

답변

2
if(Key.isDown(Key.getCode("a")) this.direction -= 1; 

해야한다.

if(Key.isDown(Key.getCode("a"))) this.direction -= 1; 
//       ^added 

동일한 문제가있는 줄이 여러 개인 경우 모두 수정하십시오.

2

모든 if 문에 닫는 괄호가 없습니다. 그들은 당신이 3 오프닝 괄호가 있고, 단지 2 닫는 사람

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(); 
관련 문제