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)

This commit is contained in:
photonstorm 2014-11-25 22:21:11 +00:00
parent 3d3920efab
commit 667d477a16
3 changed files with 8 additions and 14 deletions

View file

@ -250,6 +250,7 @@ This fixes a bug in FF where it would use the default DOMMouseWheel (thanks @pns
* Group.iterate can now accept undefined/null as the arguments (thanks @pnstickne #1353 @tasos-ch #1352)
* 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)
* Text.lineSpacing works correctly again. Before no space was added between the lines (thanks @intimidate #1367 and @brejep #1366)
* 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)
### Pixi 2.1.0 New Features

View file

@ -677,6 +677,11 @@ Phaser.Physics.P2.Body.prototype = {
this.sprite.rotation = this.data.angle;
}
if (this.debugBody)
{
this.debugBody.updateSpriteTransform();
}
},
/**
@ -769,7 +774,7 @@ Phaser.Physics.P2.Body.prototype = {
if (this.debugBody)
{
this.debugBody.destroy();
this.debugBody.destroy(true, true);
}
this.debugBody = null;

View file

@ -63,17 +63,6 @@ Phaser.Physics.P2.BodyDebug.prototype.constructor = Phaser.Physics.P2.BodyDebug;
Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, {
/**
* Core update.
*
* @method Phaser.Physics.P2.BodyDebug#update
*/
update: function() {
this.updateSpriteTransform();
},
/**
* Core update.
*
@ -83,8 +72,7 @@ Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, {
this.position.x = this.body.position[0] * this.ppu;
this.position.y = this.body.position[1] * this.ppu;
return this.rotation = this.body.angle;
this.rotation = this.body.angle;
},