From 4562939e4e17ebca3e637afeb8383ff58987c404 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Fri, 28 Feb 2014 06:17:18 +0000 Subject: [PATCH] Fixed stupid error in destroy(). --- src/gameobjects/BitmapText.js | 9 ++++++++- src/gameobjects/Graphics.js | 9 ++++++++- src/gameobjects/Image.js | 9 ++++++++- src/gameobjects/Sprite.js | 9 ++++++++- src/gameobjects/Text.js | 9 ++++++++- src/gameobjects/TileSprite.js | 9 ++++++++- src/physics/Body.js | 1 + 7 files changed, 49 insertions(+), 6 deletions(-) diff --git a/src/gameobjects/BitmapText.js b/src/gameobjects/BitmapText.js index 5aadb45a..a4292e00 100644 --- a/src/gameobjects/BitmapText.js +++ b/src/gameobjects/BitmapText.js @@ -211,7 +211,14 @@ Phaser.BitmapText.prototype.destroy = function(destroyChildren) { if (this.parent) { - this.parent.remove(this); + if (this.parent.instanceof Phaser.Group) + { + this.parent.remove(this); + } + else + { + this.parent.removeChild(this); + } } var i = this.children.length; diff --git a/src/gameobjects/Graphics.js b/src/gameobjects/Graphics.js index 0a06d5f3..9b3bc9d9 100644 --- a/src/gameobjects/Graphics.js +++ b/src/gameobjects/Graphics.js @@ -148,7 +148,14 @@ Phaser.Graphics.prototype.destroy = function(destroyChildren) { if (this.parent) { - this.parent.remove(this); + if (this.parent.instanceof Phaser.Group) + { + this.parent.remove(this); + } + else + { + this.parent.removeChild(this); + } } var i = this.children.length; diff --git a/src/gameobjects/Image.js b/src/gameobjects/Image.js index d1dfc186..c510c441 100644 --- a/src/gameobjects/Image.js +++ b/src/gameobjects/Image.js @@ -376,7 +376,14 @@ Phaser.Image.prototype.destroy = function(destroyChildren) { if (this.parent) { - this.parent.remove(this); + if (this.parent.instanceof Phaser.Group) + { + this.parent.remove(this); + } + else + { + this.parent.removeChild(this); + } } if (this.events) diff --git a/src/gameobjects/Sprite.js b/src/gameobjects/Sprite.js index 746211b9..d12b5f65 100644 --- a/src/gameobjects/Sprite.js +++ b/src/gameobjects/Sprite.js @@ -499,7 +499,14 @@ Phaser.Sprite.prototype.destroy = function(destroyChildren) { if (this.parent) { - this.parent.remove(this); + if (this.parent.instanceof Phaser.Group) + { + this.parent.remove(this); + } + else + { + this.parent.removeChild(this); + } } if (this.input) diff --git a/src/gameobjects/Text.js b/src/gameobjects/Text.js index 9f5ce778..285bf730 100644 --- a/src/gameobjects/Text.js +++ b/src/gameobjects/Text.js @@ -191,7 +191,14 @@ Phaser.Text.prototype.destroy = function (destroyChildren) { if (this.parent) { - this.parent.remove(this); + if (this.parent.instanceof Phaser.Group) + { + this.parent.remove(this); + } + else + { + this.parent.removeChild(this); + } } this.texture.destroy(); diff --git a/src/gameobjects/TileSprite.js b/src/gameobjects/TileSprite.js index 96b05dc1..10729464 100644 --- a/src/gameobjects/TileSprite.js +++ b/src/gameobjects/TileSprite.js @@ -291,7 +291,14 @@ Phaser.TileSprite.prototype.destroy = function(destroyChildren) { if (this.parent) { - this.parent.remove(this); + if (this.parent.instanceof Phaser.Group) + { + this.parent.remove(this); + } + else + { + this.parent.removeChild(this); + } } this.animations.destroy(); diff --git a/src/physics/Body.js b/src/physics/Body.js index 70dc7cf8..8f6d945b 100644 --- a/src/physics/Body.js +++ b/src/physics/Body.js @@ -9,6 +9,7 @@ * These properties affect how the body reacts to forces, what forces it generates on itself (to simulate friction), and how it reacts to collisions in the scene. * In most cases, the properties are used to simulate physical effects. Each body also has its own property values that determine exactly how it reacts to forces and collisions in the scene. * By default a single Rectangle shape is added to the Body that matches the dimensions of the parent Sprite. See addShape, removeShape, clearShapes to add extra shapes around the Body. +* Note: When bound to a Sprite to avoid single-pixel jitters on mobile devices we strongly recommend using Sprite sizes that are even on both axis, i.e. 128x128 not 127x127. * * @class Phaser.Physics.Body * @classdesc Physics Body Constructor