1 decade ago by trigoletto
I've been playing with some box2d examples and got stuck on this error:
The line 189 that the error log points is the this.parent() in my update function
cars.js
main.js
Any thoughts?
Uncaught TypeError: Cannot call method 'GetPosition' of null entity.js:47
Uncaught TypeError: Cannot call method 'GetPosition' of null entity.js:47 ig.Box2DEntity.ig.Entity.extend.update entity.js:47 ig.Box2DEntity.extend.update cars.js:189 (anonymous function) impact.js:448 ig.Game.ig.Class.extend.updateEntities game.js:212 ig.Game.ig.Class.extend.update game.js:189 ig.Box2DGame.ig.Game.extend.update game.js:121 (anonymous function) impact.js:448 ig.Box2DGame.extend.update main.js:68 (anonymous function) impact.js:448 ig.Game.ig.Class.extend.run game.js:170 ig.System.ig.Class.extend.run system.js:101 animate impact.js:376
The line 189 that the error log points is the this.parent() in my update function
cars.js
update: function() { //killOrthogonalVelocity(this.leftWheel); //killOrthogonalVelocity(this.rightWheel); //killOrthogonalVelocity(this.leftRearWheel); //killOrthogonalVelocity(this.rightRearWheel); // Key pressed if( ig.input.pressed('accelerate') ) { this.carBody.WakeUp(); engineSpeed = -HORSEPOWERS; } if( ig.input.pressed('brake') ) { engineSpeed = HORSEPOWERS; } if( ig.input.pressed('turnleft') ) { steeringAngle = MAX_STEER_ANGLE } if( ig.input.pressed('turnright') ) { steeringAngle = -MAX_STEER_ANGLE } // Key released if(( ig.input.released('accelerate') ) || (ig.input.released('brake'))) { engineSpeed = 0; } if(( ig.input.released('turnleft') ) || (ig.input.released('turnright'))) { steeringAngle = 0; } this.parent(); }
main.js
update: function() { // screen follows the player var player = this.getEntitiesByType( EntityCars )[0]; if(player) { this.screen.x = player.pos.x - ig.system.width/2; this.screen.y = player.pos.y - ig.system.height/2; } // Update all entities and backgroundMaps this.parent(); }
Any thoughts?