mirror of
https://github.com/photonstorm/phaser
synced 2024-11-26 22:52:14 +00:00
Fix for issue #917, Physics.P2.Body#addToWorld
Fix for issue #917: Calling reset() on Sprite with a P2 body can result in body.data.world == null. Calling addToWorld() would previously not check the _toRemove array, which could, if the timing were right, result in a Sprite being revived but then removed from the P2 World--the result of this being the Sprite's data would be in a mixed state causing it to appear visually but not function in the world.
This commit is contained in:
parent
33a8bfdef0
commit
36d70697db
1 changed files with 11 additions and 0 deletions
|
@ -719,6 +719,17 @@ Phaser.Physics.P2.Body.prototype = {
|
|||
*/
|
||||
addToWorld: function () {
|
||||
|
||||
if (this.game.physics.p2._toRemove)
|
||||
{
|
||||
for (var i = 0; i < this.game.physics.p2._toRemove.length; i++)
|
||||
{
|
||||
if (this.game.physics.p2._toRemove[i] === this)
|
||||
{
|
||||
this.game.physics.p2._toRemove.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.data.world !== this.game.physics.p2.world)
|
||||
{
|
||||
this.game.physics.p2.addBody(this);
|
||||
|
|
Loading…
Reference in a new issue