What is the best performant approach?

Hi All,

I have a confusion in the approach that we follow to make the game in general, like if we have 5 nodes in a scene and we are making 4 nodes inactive and 1 active that is needed (likewise for all the nodes), or removing the children and adding them to the container whenever we are going to need them back.

I see that you are confused about the performance of 2 solutions.
Performance by removing and re-adding nodes and performance by activating or deactivating nodes

  1. The time consuming way to add nodes is when addChild is added to the scene. Activating/deactivating a node takes time when node.active iterates through and refreshes all the states of the node.
  2. Both of these methods are time consuming.

One recommended way is to make the desired node a resident node (not an engine resident node, but a node that is not removed from the node tree) and later move it into the scene when it needs to be rendered. When not needed for rendering, move out of the scene.

1 Like

Can you please elaborate on this with a small example? it is interesting also I am not getting what is resident node exactly is.

For example you can do the following :
If we say you created a button than changes the menu state fron inactive to active … instead of doing so you can do the following :
1.Make the menu active and set it position to outside of the scene
2.When clicking on the button you change the menu position to the desired position inside the scene
I hope that helped :))

yeah, I understood
This approach is the best one in terms of performance.
I will follow this approach


1 Like