Why does FlxGroup have recursive kill() but not recursive revive()?

97 views
Skip to first unread message

Daniel Fedor

unread,
Apr 2, 2015, 7:26:30 PM4/2/15
to haxef...@googlegroups.com
Hey folks!

I was wondering why FlxGroup recursively kill()s all members, but revive() is only implemented in FlxBasic? 

I.e. if I FlxGroup.kill(), all members call kill(). 
If I FlxGroup.revive(), only the group revive()s. Members remain kill()ed.

This always seemed confusing to me, and I wondered why it wasn't consistent. Back in 2011, when I started using Flixel (AS3), I just assumed this was an oversight, and modified my local copy of FlxGroup to implement a recursive revive().

However, now that I'm porting the code to HaxeFlixel, I see that it is still using a non-recursive revive(). I could do the same this time around, but I'd like to be staying current with HaxeFlixel updates, so maybe I need to change my approach.

I guess a follow-up question is: if this is the intended behavior, what is the appropriate way to revive a group and all members recursively? Is it:

var grpTest:FlxGroup = new FlxGroup();
grpTest
.kill();
grpTest
.revive();
grpTest
.callAll("revive");



Thanks!

Gama11

unread,
Apr 3, 2015, 3:02:28 AM4/3/15
to haxef...@googlegroups.com
This has actually been done on the dev branch.

As for the currently released version, I don't think callAll() is a good solution. Accessing methods by their name uses Reflection, which is not only poor style / not statically typed, but also very slow. That's why callAll() and setAll() have been removed on the current dev branch. Instead, it's much nicer to do something like:

grpTest.forEach(function(member) member.revive());

Daniel Fedor

unread,
Apr 7, 2015, 2:16:58 PM4/7/15
to haxef...@googlegroups.com
Ah, that clarifies things. Thanks!
Reply all
Reply to author
Forward
0 new messages