mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 22:18:29 +00:00
Group.add and Group.addAt will only create a Physics Body on the child if it doesn't already have one. This is a change from 2.3 where it would replace the physics body property with the new body, but this could lead to garbage build-up over time, so you should now properly destroy the body before changing it.
This commit is contained in:
parent
3ad60b815b
commit
1438248388
2 changed files with 13 additions and 2 deletions
|
@ -254,6 +254,7 @@ Version 2.4 - "Katar" - in dev
|
|||
* Frame.uuid has been removed (was flagged as deprecated for several releases). This has a two-fold effect: First it means that the property no longer exists and secondly it means that the AnimationParser (the class responsible for loading sprite sheets and texture atlases) no longer has to call either RandomDataGenerator.uuid OR populates the PIXI.TextureCache. The first saves some CPU time and the second saves memory by not creating references to textures it doesn't ever use. The PIXI.TextureCache is now ignored by Phaser other than for the `__missing` and `__default` textures.
|
||||
* Phaser.AnimationParser methods `JSONData`, `JSONDataHash` and `XMLData` have all had their `cacheKey` parameter removed as it's no longer used.
|
||||
* Input.deleteMoveCallback no longer takes an integer as its parameter. Now you have to give it the original callback and context in order to remove it. This is to protect against index invalidation (see the fixed Bugs list)
|
||||
* Group.add and Group.addAt will only create a Physics Body on the child if it doesn't already have one. This is a change from 2.3 where it would replace the physics body property with the new body, but this could lead to garbage build-up over time, so you should now properly destroy the body before changing it.
|
||||
|
||||
### New Features
|
||||
|
||||
|
|
|
@ -268,6 +268,8 @@ Phaser.Group.SORT_DESCENDING = 1;
|
|||
*
|
||||
* The child is automatically added to the top of the group and is displayed on top of every previous child.
|
||||
*
|
||||
* If Group.enableBody is set then a physics body will be created on the object, so long as one does not already exist.
|
||||
*
|
||||
* Use {@link #addAt} to control where a child is added. Use {@link #create} to create and add a new child.
|
||||
*
|
||||
* @method Phaser.Group#add
|
||||
|
@ -285,10 +287,14 @@ Phaser.Group.prototype.add = function (child, silent) {
|
|||
|
||||
child.z = this.children.length;
|
||||
|
||||
if (this.enableBody)
|
||||
if (this.enableBody && child.body === null)
|
||||
{
|
||||
this.game.physics.enable(child, this.physicsBodyType);
|
||||
}
|
||||
else if (child.body)
|
||||
{
|
||||
this.addToHash(child);
|
||||
}
|
||||
|
||||
if (!silent && child.events)
|
||||
{
|
||||
|
@ -402,10 +408,14 @@ Phaser.Group.prototype.addAt = function (child, index, silent) {
|
|||
|
||||
this.updateZ();
|
||||
|
||||
if (this.enableBody)
|
||||
if (this.enableBody && child.body === null)
|
||||
{
|
||||
this.game.physics.enable(child, this.physicsBodyType);
|
||||
}
|
||||
else if (child.body)
|
||||
{
|
||||
this.addToHash(child);
|
||||
}
|
||||
|
||||
if (!silent && child.events)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue