Skip to content

Commit 4562939

Browse files
committed
Fixed stupid error in destroy().
1 parent e45a929 commit 4562939

7 files changed

Lines changed: 49 additions & 6 deletions

File tree

src/gameobjects/BitmapText.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,14 @@ Phaser.BitmapText.prototype.destroy = function(destroyChildren) {
211211

212212
if (this.parent)
213213
{
214-
this.parent.remove(this);
214+
if (this.parent.instanceof Phaser.Group)
215+
{
216+
this.parent.remove(this);
217+
}
218+
else
219+
{
220+
this.parent.removeChild(this);
221+
}
215222
}
216223

217224
var i = this.children.length;

src/gameobjects/Graphics.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,14 @@ Phaser.Graphics.prototype.destroy = function(destroyChildren) {
148148

149149
if (this.parent)
150150
{
151-
this.parent.remove(this);
151+
if (this.parent.instanceof Phaser.Group)
152+
{
153+
this.parent.remove(this);
154+
}
155+
else
156+
{
157+
this.parent.removeChild(this);
158+
}
152159
}
153160

154161
var i = this.children.length;

src/gameobjects/Image.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,14 @@ Phaser.Image.prototype.destroy = function(destroyChildren) {
376376

377377
if (this.parent)
378378
{
379-
this.parent.remove(this);
379+
if (this.parent.instanceof Phaser.Group)
380+
{
381+
this.parent.remove(this);
382+
}
383+
else
384+
{
385+
this.parent.removeChild(this);
386+
}
380387
}
381388

382389
if (this.events)

src/gameobjects/Sprite.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,14 @@ Phaser.Sprite.prototype.destroy = function(destroyChildren) {
499499

500500
if (this.parent)
501501
{
502-
this.parent.remove(this);
502+
if (this.parent.instanceof Phaser.Group)
503+
{
504+
this.parent.remove(this);
505+
}
506+
else
507+
{
508+
this.parent.removeChild(this);
509+
}
503510
}
504511

505512
if (this.input)

src/gameobjects/Text.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,14 @@ Phaser.Text.prototype.destroy = function (destroyChildren) {
191191

192192
if (this.parent)
193193
{
194-
this.parent.remove(this);
194+
if (this.parent.instanceof Phaser.Group)
195+
{
196+
this.parent.remove(this);
197+
}
198+
else
199+
{
200+
this.parent.removeChild(this);
201+
}
195202
}
196203

197204
this.texture.destroy();

src/gameobjects/TileSprite.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,14 @@ Phaser.TileSprite.prototype.destroy = function(destroyChildren) {
291291

292292
if (this.parent)
293293
{
294-
this.parent.remove(this);
294+
if (this.parent.instanceof Phaser.Group)
295+
{
296+
this.parent.remove(this);
297+
}
298+
else
299+
{
300+
this.parent.removeChild(this);
301+
}
295302
}
296303

297304
this.animations.destroy();

src/physics/Body.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* 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.
1010
* 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.
1111
* 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.
12+
* 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.
1213
*
1314
* @class Phaser.Physics.Body
1415
* @classdesc Physics Body Constructor

0 commit comments

Comments
 (0)