Skip to content

How to wrap a component? #911

Answered by spydon
st-pasha asked this question in Q&A
Aug 10, 2021 · 1 comments · 5 replies
Discussion options

You must be logged in to vote

Edit: this was solved by #906 and component.changeParent

Good idea! This should be pretty easy to implement.
With replaceChild I would expect W to fully take X place in the tree though, and not wrap X, but maybe that is what you meant with the W(X) notation, that X is added to W there already?
I'm guessing we need quite a lot of optional parameters for the method too, since for a PositionComponent you might want it to take the position, size, scale or angle of the component that it replaces too.

Right now you would have to do something like this:

v.remove(x);
w.changePriorityWithoutResorting(x.priority);
// wait for next tick
x.shouldRemove = false;
w.addChild(x);
v.add(w);

After #906 you…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@st-pasha
Comment options

@st-pasha
Comment options

@spydon
Comment options

@spydon
Comment options

@st-pasha
Comment options

Answer selected by spydon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants