안녕하세요. 다시 게임 코드에서 학교용 결함이 발생했습니다. 이제 "Player Rocket"을 추가하려고합니다. 코드입니다. 이 책은 내가 생성 된 모든 소행성 아래에 추가했다. Uncaught TypeError : 정의되지 않은 'vX'속성을 설정할 수 없습니다.
player.vX = 0;
player.vY = 0;
if (player.moveRight) {
player.vX = 3;
};
if (player.moveUp) {
player.vY = -3;
};
if (player.moveDown) {
player.vY = 3;
};
player.x += player.vX;
player.y += player.vY;
context.fillStyle = 'rgb(255, 0, 0)';
context.beginPath();
context.moveTo(player.x+player.halfWidth, player.y);
context.lineTo(player.x-player.halfWidth, player.y-player.halfHeight);
context.lineTo(player.x-player.halfWidth, player.y+player.healfHeight);
context.closePath();
context.fill();
이제 오류가 나는 곳 어떤이를 정의했다하지만 난 아무것도 그리워하지 않은 경우 나는 책을 통해 검토 한
Uncaught TypeError: Cannot set property 'vX' of undefined
보고 ... 그것은이가 계속. 지금 나는 아직도 이것에 정말로 새롭다. 그러나 나를 만나는 유일한 지점은 player.vX
다.
var player;
var Player = function(x, y){
this.x = x;
this.y = y;
this.width = 24;
this.height = 24;
this.halfWidth = this.width/2;
this.halfHeight = this.height/2;
this.moveRight = false;
this.moveUp = false;
this.moveDown = false;
this.vX = 0;
this.vY = 0;
};
누구든지 나를 도와 줄 수 있다면 좋을 것입니다. 고맙습니다!!!
를 살펴한다? – Misters
해당 코드가 책에서 나온 경우 책을 창 밖으로 던져 다른 책을 찾으십시오. – adeneo
당신은이 수수께끼에 그것을 게시 할 수 있습니까? 그래서 우리는이 모든 캔버스 것들로 직접 오류를 볼 수 있습니까? 감사합니다 – xhallix