mirror of
https://github.com/wassname/phaser.git
synced 2026-07-09 00:20:17 +08:00
Buttons are now cleanly destroyed if part of a Group without leaving their InputHandler running.
You can now safely destroy a Group and the 'destroyChildren' boolean will propogate fully down the display list. Calling destroy on an already destroyed object would throw a run-time error. Now checked for and aborted. Calling destroy while in an Input Event callback now works for either the parent Group or the calling object itself. In Group.destroy the default for 'destroyChildren' was false. It's now `true` as this is a far more likely requirement when destroying a Group. All GameObjects now have a 'destroyChildren' boolean as a parameter to their destroy method. It's default is true and the value propogates down its children.
This commit is contained in:
@@ -201,8 +201,13 @@ Phaser.BitmapText.prototype.postUpdate = function () {
|
||||
/**
|
||||
* Destroy this BitmapText instance. This will remove any filters and un-parent any children.
|
||||
* @method Phaser.BitmapText.prototype.destroy
|
||||
* @param {boolean} [destroyChildren=true] - Should every child of this object have its destroy method called?
|
||||
*/
|
||||
Phaser.BitmapText.prototype.destroy = function() {
|
||||
Phaser.BitmapText.prototype.destroy = function(destroyChildren) {
|
||||
|
||||
if (this.game === null) { return; }
|
||||
|
||||
if (typeof destroyChildren === 'undefined') { destroyChildren = true; }
|
||||
|
||||
if (this.parent)
|
||||
{
|
||||
@@ -211,9 +216,26 @@ Phaser.BitmapText.prototype.destroy = function() {
|
||||
|
||||
var i = this.children.length;
|
||||
|
||||
while (i--)
|
||||
if (destroyChildren)
|
||||
{
|
||||
this.removeChild(this.children[i]);
|
||||
while (i--)
|
||||
{
|
||||
if (this.children[i].destroy)
|
||||
{
|
||||
this.children[i].destroy(destroyChildren);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.removeChild(this.children[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (i--)
|
||||
{
|
||||
this.removeChild(this.children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.exists = false;
|
||||
|
||||
Reference in New Issue
Block a user