• Content Count

  • Joined

  • Last visited

Everything posted by Rodion

  1. I found one example, everything works, but is it right to do so? example collision in matter'collisionstart', function (event) { for (var i = 0; i < event.pairs.length; i++) { var bodyA = getRootBody(event.pairs[i].bodyA); var bodyB = getRootBody(event.pairs[i].bodyB); if ((bodyA.label === 'barrel' && bodyB.label === 'tank') || (bodyB.label === 'barrel' && bodyA.label === 'tank')) { bangBarrel(); } } }, this); function getRootBody(body) { if (body.parent === body) { return body; } while (body.parent !== body) { body = body.parent; } return body; }
  2. Please tell me. in the physical engine 'arcade' everything is very simple: gameObject.physics.add.collider(tank, barrel, bangBarre´╗┐l´╗┐); how to do this in 'matter'?
  3. Hello, I'm using Phaser 3 and the physics engine matter. I need to call a function when one object collides with a particular object. For example I have a tank, barrels, hearts. Then there will be bullets, other tanks, some other objects. You need to call the function when the tank collides with the barrel, it should explode, and if it collides with the heart, it will replenish life.'collisionstart', function (event) { bangBarrel(); }); this method calls the function in any collision. How to trigger the function when the tank collide with the barrel, and how to trigger the function when the tank collide with the heart?