Reputation: 464
I'm making a Sprite kit game. There I have a button, which have to be hidden, while some condition won't be true. So I add this button to the scene and make it hidden. So which way is better ones? To make a button, add it to the scene and make it hidden? Or add it to the scene, when I need it?
Upvotes: 0
Views: 103
Reputation: 16827
If you do not plan on using the button a lot, then do not add it. We do not know for certain what optimizations get done on hidden objects, so it is possible that it will still be a part of the drawing process and just skipped. If you find yourself needing to flash the button on and off in rapid session, then you would want to add it to the scene and use the hidden property. Now the performance loss is minimal, so also consider your time in the matter. Is it going to be more work for you to do add/remove, or is it the same as hidden? Take things like this into consideration.
Upvotes: 5