Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FlxContainer - a group that removes members from other containers #3050

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

Geokureli
Copy link
Member

@Geokureli Geokureli commented Feb 28, 2024

A FlxContainer is a FlxGroup that removes it's members from their previous container, when added, meaning a FlxBasic can only ever be in one container at a time. The main benefits is that it ensures a FlxBasic is only in the draw-tree once, where FlxGroups can result in sprites being drawn or updated twice per frame.

The long term goal of this change is to replace FlxSpriteGroup and FlxNestedSprite with a system closer to Flash's DisplayObjectContainer tree, where object's x and y may refer to it's local position in the parent, but the global position may be calculated at any time by iterating up the "parents" until reaching the state. Many flixel features currently can only truly know where a sprite will actually be drawn while in the draw() phase, especially when there are multiple cameras with different zooms.

Related: #2715
By adding a drawContext arg to draw we will be able to pass down vars that dictate how objects are drawn, so in this proposed replacement for FlxSpriteGroup and FlxNestedSprite a parent collection with (for instance) x, y, angle, scale properties will augment the context's transformation matrix with it's properties before passing it to it's members, that will use it to draw their "global" position

@Geokureli Geokureli added this to the 5.7.0 milestone Feb 28, 2024
@Geokureli Geokureli changed the title Add FlxContainer - a group that removes members from other groups Add FlxContainer - a group that removes members from other containers Feb 28, 2024
@Geokureli Geokureli merged commit 241d968 into HaxeFlixel:dev Feb 28, 2024
12 of 16 checks passed
@Geokureli Geokureli deleted the container branch February 28, 2024 21:33
Geokureli added a commit that referenced this pull request Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant