iShellz Posted March 17, 2014 Share Posted March 17, 2014 Uncaught TypeError: Cannot call method 'hasOwnProperty' of null phaser.min.js:20 Phaser.Physics.P2.enableBodyphaser.min.js:20 Phaser.Physics.P2.enable Getting an error like this once the group reaches the the last member Link to comment Share on other sites More sharing options...
rich Posted March 17, 2014 Share Posted March 17, 2014 Paste your code. Link to comment Share on other sites More sharing options...
iShellz Posted March 17, 2014 Author Share Posted March 17, 2014 IN CREATE neckGroup.setAll('checkWorldBounds', true); neckGroup.setAll('outOfBoundsKill', true); neckGroup.enableBody = true; addNeck() (Called on a loop) var neck = neckGroup.getFirstDead(); neck.body.clearShapes(); neck.body.loadPolygon('pData', 'neck'); neck.reset(320, 400); neck.body.setZeroVelocity(); neck.body.data.gravityScale = 0.0; neck.body.fixedRotation = true; neck.body.velocity.x = 0; neck.body.moveLeft(400); It also is still colliding with the world bounds. Link to comment Share on other sites More sharing options...
iShellz Posted March 18, 2014 Author Share Posted March 18, 2014 changed to neck.body.checkWorldBounds = true; neck.body.outOfBoundsKill = true; neck.body.collideWorldBounds = false; They are not killed when they leave the world, they leave and i receive the same error as before. Link to comment Share on other sites More sharing options...
iShellz Posted March 18, 2014 Author Share Posted March 18, 2014 neck.events.onOutOfBounds.add(out, this); will not fire as well, even with outOfBoundsKill commented out Link to comment Share on other sites More sharing options...
iShellz Posted March 19, 2014 Author Share Posted March 19, 2014 haven't figured this out yet ------------------------------ So I managed to get this to sort of work. I have run into a new problem with the new code below. function addNeck() { var neck = neckGroup.getFirstDead(); game.physics.p2.enable(neck, true); neck.body.clearShapes(); neck.body.loadPolygon('pData', 'neck'); neck.reset(320, 400); neck.body.setZeroVelocity(); neck.body.data.gravityScale = 0.0; neck.body.fixedRotation = true; neck.body.setZeroVelocity(); neck.body.moveLeft(150); neck.events.onOutOfBounds.add(neckOut, this); neck.checkWorldBounds = true; neck.body.collideWorldBounds = false; } function neckOut(neck) { neck.kill(); } The group is created with 5 sprites in the create phase. After the first to move and leave the screen the next 2 ignore the speed set in the addNeck function and collide with the world bounds. I have no idea whats going on because the first to work perfect. Link to comment Share on other sites More sharing options...
iShellz Posted March 20, 2014 Author Share Posted March 20, 2014 SOLVED I moved everything to the create step instead of a loop function setting values. Link to comment Share on other sites More sharing options...
Recommended Posts