Jump to content

outOfBoundKill and P2 Physics


iShellz
 Share

Recommended Posts

        

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

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

haven't figured this out yet  :unsure:

 

------------------------------

 

 

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...