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

Replace FlxGroups with FlxContainers #60

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Geokureli
Copy link

The following is copied from this PR:

A FlxContainer is a FlxGroup that removes it's members from their previous container, when added. This means 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, unlike FlxGroups which can cause sprites to be drawn or updated twice per frame. The rule of thumb is: FlxGroups are for organizing (e.g. for collision or iterating) where Containers are for drawing and updating

The long term goal of containers 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.

The main benefit of this change is that flixel objects added to containers have a reference to their container, and container's properties. This is useful on it's own, particularly for features I'm working on in a project, but fixes a lot of rendering issues. Previously there were issues when UI elements were not on the main camera, since sprites with null cameras draw to their parent's cameras, and there was no way to know which camera that would be unless you were in that sprite's draw() call

@Geokureli
Copy link
Author

Geokureli commented Feb 7, 2025

this is now ready

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