Hi, Hersir!
I'm developing a game built on FlxNestedSprite
. The group positioning/scaling/rotating is really convenient, and is the kind you are looking for.
I can tell you my work around for your "Every Child Must be a FlxNestedSprite
" issue.
I just created a base class that extends FlxNestedSprite
, that has some logic built in to copy any other sprite, either on load, every frame, or when you need it to.
For example, FlxText
, which cannot be added directly as a child to a FlxNestedSprite
. I just use this helper class:
package sprite;
import flixel.addons.display.FlxNestedSprite;
import flixel.text.FlxText;
import flixel.util.FlxColor;
class FlxNestedTextSprite extends FlxNestedSprite
{
private var text:FlxText;
private var fontPath:String;
private var message:String;
private var textBoxAlign:String;
private var size:Int;
private var textColor:FlxColor;
public function new(message:String, fontPath:String,
size:Int=10, textColor:FlxColor=FlxColor.WHITE,
textBoxAlign:String="left")
{
super();
this.message = message;
this.fontPath = fontPath;
this.size = size;
this.textColor = textColor;
this.textBoxAlign = textBoxAlign;
text = new FlxText(0, 0, 0, message);
text.setFormat(fontPath, size, textColor, "left");
copyFlxTextToSprite(this, text);
}
private function copyFlxTextToSprite(destinationSprite:FlxSprite,
sourceText:FlxText):Void
{
sourceText.drawFrame(true);
destinationSprite.loadGraphicFromSprite(sourceText);
}
}
If you need to add some other non-FlxNestedSprite
as a child, you can do something similar.
Hope that helps!