이 클래스를 정의하고 나중에 인스턴스화하고 메소드 중 일부를 호출하려고한다.I 자바 스크립트에서 어떤 객체의 메소드도 호출 할 수 없다.
function Layer(){
this.image = null;
this.owned = false;
this.sim = false;
this.pos = 0.5;
this.vel = 0;
this.acc = 0;
this.lastup = millis();
this.newpos = 0;
this.scrub = scrub;
function scrub(npos){
this.newpos = npos;
this.vel = 0;
this.acc = 0;
}
}
dummy = new Layer();
dummy.scrub(0.8);
// chrome says Uncaught TypeError: Object #<an Object> has no method 'scrub'
정확하게 정의 할 수 있습니까?
이 this.scrub = 스크럽을 삭제; – Chris
'millis'는 어디에 정의되어 있습니까? –
@Chris - 오류가 * 발생할 수 있습니다. –