One of the more powerful aspects of groups is FlxTypedGroup.recycle()
.
// revive the next dead object in the group,
// or create a new one if we haven't reached maxSize
sprite = group.recycle(Sprite.new);
This is very useful for things like bullets, particles, enemy spawns, etc, where you don’t want to call new()
frequently.
Note:
FlxTypedGroup.recycle()
will act differently depending on if the group has a maxSize
defined or not.