[WIP] [Proposal] Return of the Stage
See original GitHub issueWork In Progress
Leave your comments. The more people want it, the more time pixi team will look into it 😃
Also available here: https://github.com/pixijs/pixi.js/wiki/v5-Proposal%2C-Return-of-the-Stage
Problem
- Child has no way to know whether parent was removed from the stage.
- The Destroy API is horrible, we just ask people to maintain it on their side, but we dont give any tools to determine the moment object leaves the stage, and user has to implement refcounting on their side.
- There is no way to differentiate container from the root element, this flag is maintained by user.
- Recursive calls of add/remove complicates the stacktrace, and problems in remove/destroy appear too often, we cannot isolate them, user will see the mess anyway.
Possible problems with naive implementations:
- If we simply pass ‘added’ and ‘removed’ messages recursively it will affect performance when we construct difficult scene.
- Any simple manipulation within the stage, like moving an element from one subtree to another will fire those events and possibly trigger some destroy sequence.
- If we just add special flag in “removeChild” that won’t be good because people are having problems searching that flag in cocos2d engine, its not intuitive.
- Porting old code may be difficult if we force usage of the stage. We must ensure compatibility with old “container as root” approach.
- There might be cases with multiple stages inside each other. We have to resolve it somehow, stage needs to know about its
parentStage
.
Solution
- Put big sign for users DO NOT MODIFY
children
PROPERTY. - Mark all display objects with UniqueID
- Stage is Container that must store all its children in set by their ID. Elements store a link to the stage they were added.
- If subtree is added/removed to the stage, fire
added
/removed
event through whole subtree and re-assignstage
field for all elements. - Add
detachChild
method that does not fireremoved
but adds whole subtree to special stage’sdetached
set of elements, that can be removed on next frame, if user says so, or if special flag is enabled. Calling “addChild” on detached elements adds them back, withoutadded
signal/event. - Add/remove/detach works like in pixi-v4 when there is no Stage parent. Allow free modification of
children
in that case. - If the stage added inside another stage, it behaves as a single element: no recursive
added
/removed
. - All those manipulations must use BFS (queue) instead of recursion. It simplifies the debug process for users.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:22
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to Create a Successful Proposal - WIP HQ Event - YouTube
All-star Women In Product Conference 2020 speakers, Kalia Aragon (Product Manager, Disney Streaming Services), Jessica Cherny (Head of Data ...
Read more >babel/proposals: ✍️ Tracking the status of Babel's ... - GitHub
This way everyone is moving towards Stage 4 and closer to what will be in the spec if the proposal makes it to...
Read more >Proposal for Work In Progress (WIP) workflow - Google Git
Add a new property for unmerged changes called wip, for “work-in-progress” changes. A WIP change is a change that is not currently ready...
Read more >Abstract submission - WIP 2022 - CongressLine
After you submit your proposal, you can still re-enter the submission link at any time to view and edit your Abstract until the...
Read more >[WIP #6] - Wonderland Moderator Compensation
Objective: The objective of this proposal is to outline expectations, provide reasonable compensation to selected members of the moderation team ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@PainKKKiller Please use the reactions to +1 rather than posting a +1 comment. Thanks!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.