Jump to content

Problem with P2 physics


newknight
 Share

Recommended Posts

Hello all,
I have a problem with Phaser P2 physics in short i have 2 groups with objects. One is for my projectiles and the other is for enemies. The problem is that i want when projectile hits an enemy, the enemy should not move (it bounce back a little...).
This is the code for my enemies i set the body.kinematic = true but it doesn't work.
Thanks.

this.enemiesGroup = this.add.group();
this.enemiesGroup.enableBody = true; 

for(var i = 0; i < 3; i++){
                    for(var j = 0; j < 9; j++){
                         var tmp = this.enemiesGroup.create( 80 +(j*66), y , 'enemies_1');
                         this.physics.p2.enable(tmp, this.Debug);
                         tmp.enableBody = true;
                         tmp.physicsBodyType = Phaser.Physics.P2JS;
                         

                         tmp.name = 'enemy' + buff;
                         this.enemiesHP[tmp.name] = 100;
                         tmp.anchor.setTo(0.3);
                         tmp.angle = 90;
                         tmp.scale.setTo(0.6);

                         tmp.body.setCircle(18);
                         tmp.body.kinematic = true;

                         tmp.checkWorldBounds = true;

                         var exp = this.enemyExplosion.create(0, 0, 'explosion');
                         exp.visible = false;
                         exp.exists = false;
                         exp.anchor.setTo(0.5);

                         buff++;
                    }
                    y = y + 90;
               }

 

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...