From 0a422694797e661b086f6de635007de88d588260 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Fri, 13 Sep 2013 03:52:05 +0100 Subject: [PATCH] Group vs. Group collision working - also fixed a bug in the Body.reset function that was causing some lovely physics errors :) --- examples/collision_group_vs_group.php | 117 ++++++++++++++++++++++++++ src/particles/arcade/Emitter.js | 2 +- src/physics/arcade/Body.js | 16 ++-- 3 files changed, 125 insertions(+), 10 deletions(-) create mode 100644 examples/collision_group_vs_group.php diff --git a/examples/collision_group_vs_group.php b/examples/collision_group_vs_group.php new file mode 100644 index 00000000..0d921cf9 --- /dev/null +++ b/examples/collision_group_vs_group.php @@ -0,0 +1,117 @@ + + + + phaser.js - a new beginning + + + + + + + + \ No newline at end of file diff --git a/src/particles/arcade/Emitter.js b/src/particles/arcade/Emitter.js index cfb88507..6393abc4 100644 --- a/src/particles/arcade/Emitter.js +++ b/src/particles/arcade/Emitter.js @@ -338,7 +338,7 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () { if (this.width > 1 || this.height > 1) { - particle.reset(this.x - this.game.rnd.integerInRange(this.left, this.right), this.y - this.game.rnd.integerInRange(this.top, this.bottom)); + particle.reset(this.emiteX - this.game.rnd.integerInRange(this.left, this.right), this.emiteY - this.game.rnd.integerInRange(this.top, this.bottom)); } else { diff --git a/src/physics/arcade/Body.js b/src/physics/arcade/Body.js index 9ebe509e..741e46c2 100644 --- a/src/physics/arcade/Body.js +++ b/src/physics/arcade/Body.js @@ -205,18 +205,16 @@ Phaser.Physics.Arcade.Body.prototype = { reset: function () { - this.velocity = new Phaser.Point; - this.acceleration = new Phaser.Point; - this.drag = new Phaser.Point; - this.gravity = new Phaser.Point; - this.bounce = new Phaser.Point; - this.maxVelocity = new Phaser.Point(10000, 10000); + this.velocity.setTo(0, 0); + this.acceleration.setTo(0, 0); this.angularVelocity = 0; this.angularAcceleration = 0; - this.angularDrag = 0; - this.maxAngular = 1000; - this.mass = 1; + + this.x = (this.sprite.x - (this.sprite.anchor.x * this.width)) + this.offset.x; + this.y = (this.sprite.y - (this.sprite.anchor.y * this.height)) + this.offset.y; + this.lastX = this.x; + this.lastY = this.y; },