Group.add and Group.addAt would forget to remove the child from the hash of its previous Group if it had a physics body enabled, causing unbounded hash increase (thanks @strawlion @McIntozh #2232)

This commit is contained in:
Richard Davey 2016-02-03 21:51:01 +00:00
parent 10209dc8f5
commit a0eb44ec09
2 changed files with 12 additions and 0 deletions

View file

@ -274,6 +274,7 @@ If you are an exceptional JavaScript developer and would like to join the Phaser
* ArcadePhysics.Body.onCeiling is a new complementary method to go with onFloor (thanks @yigitozdemir #1610)
* Text.precalculateWordWrap allows you to run your text through the Text word wrap function, which is handy if you need to handle pagination on longer pieces of text (thanks @slashman #2277)
* Sprite (and all Game Objects) have a new argument in their destroy method: `destroyTexture`. This boolean (which is false by default) controls if the BaseTexture of the Game Object should be destroyed or not. This is extremely useful in situations where you've got a lot of dynamic assets you no longer need, such as textures created from BitmapDatas. You must set the `destroyTexture` argument yourself. This can be done in a custom Game Object destroy method or as part of your state shutdown (#2261)
* The Health Game Object component has a new method: `setHealth` which allows you to set the exact health amount. This is now used by the `revive` function.
### Updates
@ -320,6 +321,7 @@ If you are an exceptional JavaScript developer and would like to join the Phaser
* SinglePad.callbackContext is now set through addCallbacks method (thanks @puzzud #2161)
* Both `transparent` and `antialias` were ignored if set to `false` in a Game configuration object, as the `parseConfig` method didn't check for falsey values (thanks @amadeus #2302)
* GameObject.revive used to add the health amount given to the Game Object (via `heal`) instead of setting it as the new health amount. It now calls `setHealth` instead, giving it the exact amount (thanks @netgfx #2231)
* Group.add and Group.addAt would forget to remove the child from the hash of its previous Group if it had a physics body enabled, causing unbounded hash increase (thanks @strawlion @McIntozh #2232)
### Pixi Updates

View file

@ -289,6 +289,11 @@ Phaser.Group.prototype.add = function (child, silent) {
if (child.parent !== this)
{
if (child.body)
{
child.parent.removeFromHash(child);
}
this.addChild(child);
child.z = this.children.length;
@ -415,6 +420,11 @@ Phaser.Group.prototype.addAt = function (child, index, silent) {
if (child.parent !== this)
{
if (child.body)
{
child.parent.removeFromHash(child);
}
this.addChildAt(child, index);
this.updateZ();