From 0ac48935569f5c8dab0c24968bc007565d379c47 Mon Sep 17 00:00:00 2001 From: "Andreas Renberg (IQAndreas)" Date: Tue, 22 Oct 2013 02:17:00 +0200 Subject: [PATCH 1/2] Add `FlxGroup#killAll()` and `FlxGroup#reviveAll()` `FlxGroup#kill()` and `FlxGroup#revive()` no longer kill or revive the group's members, only the group itself. See https://github.com/FlixelCommunity/flixel/issues/30#issuecomment-26753623 --- src/org/flixel/FlxGroup.as | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/org/flixel/FlxGroup.as b/src/org/flixel/FlxGroup.as index 37051c71..3ea403e4 100644 --- a/src/org/flixel/FlxGroup.as +++ b/src/org/flixel/FlxGroup.as @@ -555,36 +555,28 @@ package org.flixel } /** - * Calls kill on the group's members and then on the group itself. + * Calls kill() on all of the group's members (but not on the group itself). */ - override public function kill():void + override public function killAll():void { - var basic:FlxBasic; var i:uint = 0; while(i < length) { - basic = members[i++] as FlxBasic; + var basic:FlxBasic = members[i++] as FlxBasic; if((basic != null) && basic.exists) basic.kill(); } - - // Kill the group itself - super.kill(); } /** - * Calls revive on the group itself and then on the group's members. + * Calls revive on all of the group's members (but not on the group itself). */ - override public function revive():void + public function reviveAll():void { - // Revive the group itself - super.revive(); - - var basic:FlxBasic; var i:uint = 0; while(i < length) { - basic = members[i++] as FlxBasic; + var basic:FlxBasic = members[i++] as FlxBasic; if((basic != null) && !basic.alive) basic.revive(); } From 4453edfb35fa998bbc83296d0c3ce952411164c2 Mon Sep 17 00:00:00 2001 From: "Andreas Renberg (IQAndreas)" Date: Tue, 22 Oct 2013 02:57:11 +0200 Subject: [PATCH 2/2] Update the ASDoc in `FlxBasic` to point out the `kill` and `revive` behaviors of `FlxGroup` ... since we are no longer overriding those methods, adding the relevant ASDoc would be possible, but seems less logical than it needs to be. It's easier just to add the information to `FlxBasic` instead. --- src/org/flixel/FlxBasic.as | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/org/flixel/FlxBasic.as b/src/org/flixel/FlxBasic.as index 70788363..5b4b85e5 100644 --- a/src/org/flixel/FlxBasic.as +++ b/src/org/flixel/FlxBasic.as @@ -126,6 +126,9 @@ package org.flixel * However, if you want the "corpse" to remain in the game, * like to animate an effect or whatever, you should override this, * setting only alive to false, and leaving exists true. + * + * When used in a FlxGroup, the method will kill the group, but leave + * the members alive; use FlxGroup.killAll() to kill any members. */ public function kill():void { @@ -136,6 +139,9 @@ package org.flixel /** * Handy function for bringing game objects "back to life". Just sets alive and exists back to true. * In practice, this function is most often called by FlxObject.reset(). + * + * When used in a FlxGroup, the method will revive the group, but leave + * the members as they were; use FlxGroup.reviveAll() to revive any members. */ public function revive():void {