Not perfect, because layers and groups are different – For my current project I need parts of an object to be in different layers for interleaving. Move together, but retain their layer. But easier to do coordinated move than all those toFront and toBack.
Then I wondered: is there a performance or stack corruption or other problem that I should worry about from all that nesting?
Your approach is essentially the recommended way (per docs) of using groups for layering.
As for performance, to quote the docs, “display groups are essentially tables.”
You should be able to use 20 to 30 groups without any issues; there’s actually no rule of thumb here, but generally 2D games use between 5 to 20 layers. I would say that you’re more likely to have an issue with too many textures than you would with “too many groups.”
Hey there!
I used the same approach to create parallax in a couple of games.
I’ve used around 30 groups in some levels and measured performance against having a single group. No difference at all! So don’t worry about it.
Thank you, but I don’t particularly like the Defold editor. Perhaps because I am an old guy, I prefer simpler editors. I use Sublime Text, does everything I need. I will note that for my colleagues, though. Thanks.