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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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