Skip to content

Commit 667d477

Browse files
committed
P2.BodyDebug always lagged behind the position of the Body it was tracking by one frame, which became visible at high speeds. It now syncs its position in the Body.postUpdate which prevents this from happening (thanks @ValueError)
1 parent 3d3920e commit 667d477

3 files changed

Lines changed: 8 additions & 14 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ This fixes a bug in FF where it would use the default DOMMouseWheel (thanks @pns
250250
* Group.iterate can now accept undefined/null as the arguments (thanks @pnstickne #1353 @tasos-ch #1352)
251251
* When you change State the P2 Physics world is no longer fully cleared. All of the bodies, springs, fixtures, materials and constraints are removed - but config settings such as gravity, restitution, the contact solver, etc are all retained. The P2.World object is only created the very first time you call Physics.startSystem. Every subsequent call hits P2.World.reset instead. This fixes "P2.World gravity broken after switching states" (and other related issues) (#1292 #1289 #1176)
252252
* Text.lineSpacing works correctly again. Before no space was added between the lines (thanks @intimidate #1367 and @brejep #1366)
253+
* P2.BodyDebug always lagged behind the position of the Body it was tracking by one frame, which became visible at high speeds. It now syncs its position in the Body.postUpdate which prevents this from happening (thanks @valueerror)
253254

254255
### Pixi 2.1.0 New Features
255256

src/physics/p2/Body.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,11 @@ Phaser.Physics.P2.Body.prototype = {
677677
this.sprite.rotation = this.data.angle;
678678
}
679679

680+
if (this.debugBody)
681+
{
682+
this.debugBody.updateSpriteTransform();
683+
}
684+
680685
},
681686

682687
/**
@@ -769,7 +774,7 @@ Phaser.Physics.P2.Body.prototype = {
769774

770775
if (this.debugBody)
771776
{
772-
this.debugBody.destroy();
777+
this.debugBody.destroy(true, true);
773778
}
774779

775780
this.debugBody = null;

src/physics/p2/BodyDebug.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,6 @@ Phaser.Physics.P2.BodyDebug.prototype.constructor = Phaser.Physics.P2.BodyDebug;
6363

6464
Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, {
6565

66-
/**
67-
* Core update.
68-
*
69-
* @method Phaser.Physics.P2.BodyDebug#update
70-
*/
71-
update: function() {
72-
73-
this.updateSpriteTransform();
74-
75-
},
76-
7766
/**
7867
* Core update.
7968
*
@@ -83,8 +72,7 @@ Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, {
8372

8473
this.position.x = this.body.position[0] * this.ppu;
8574
this.position.y = this.body.position[1] * this.ppu;
86-
87-
return this.rotation = this.body.angle;
75+
this.rotation = this.body.angle;
8876

8977
},
9078

0 commit comments

Comments
 (0)