Add FlxContainer - a group that removes members from other containers #3050
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A
FlxContainer
is aFlxGroup
that removes it's members from their previous container, when added, meaning aFlxBasic
can only ever be in one container at a time. The main benefits is that it ensures aFlxBasic
is only in the draw-tree once, whereFlxGroups
can result in sprites being drawn or updated twice per frame.The long term goal of this change is to replace
FlxSpriteGroup
andFlxNestedSprite
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
andFlxNestedSprite
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