Group rotation

  • Hi, I am stuck with small problem. I have group of sprites on screen and I need to rotate them together , using centre of group as pivot point, at the same time each individual sprite also need to be rotated so image stays as it was just position if sprite is changed. Right now I am using FlxSpriteGroup as container but as I found out its rotating each sprite individually. After some searches I found FlxNestedSprite but it forces all children to be FlxNestedSprite. I would be thankful if someone could show me some direction how to achieve container feature in HaxeFlixel :)

  • administrators

    Unfortunately, the options are pretty much limited to either FlxNestedSprite or FlxSpriteGroup right now.

  • Ok thx for info, will try to think up something.

  • Working on a solution to this as we speak. My team needs this functionality but we really enjoy using HaxeFlixel. I'll try to remember to post here when we have a solution.

  • 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, 
    		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,

    If you need to add some other non-FlxNestedSprite as a child, you can do something similar.

    Hope that helps!

Log in to reply

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.