Good day, everyone!
I’d like to ask, how you live without visible property? For example, on sprite.
I’m kinda old school developer and I want to minimize object creation in runtime. I believe, it is all about performance. So, for example, I do have character icon in game, and I have a frame, that is shown over the icon, when the character is selected. I created a collection with two sprites (one sprite is icon, second one is frame). For now, I set z coord of my frame to some large value to move it out of renderable space (and thus, make it invisible). But it seems like a hack (not a straightforward one) to me.
So the questions is:
Do you feel like you need visible property? (On sprite, collection, etc?)
msg.post("#sprite", "disable") --visible = false
msg.post("#sprite", "enable") --visible = true
2 Likes
It is important to note that Defold will preallocate and load everything your collection needs when the collection is initially loaded. Internally things such as gameobjects and are pooled as well, meaning spawning “prefab gameobjects” through factories will have minimal performance impact.
That said, it’s always good to keep performance in mind when developing your game of course.
5 Likes
Thank you, BunBunBun!
I’ll rewrite my code, to make it clearer.
By the way, can I do this in editor?
1 Like
you can do it if add the script to sprite for adding property
go.property("visible", true)
function init(self)
if not self.visible then
msg.post("#sprite", "disable")
end
end
6 Likes
It’s currently not possible, but we have a ticket registered for this: DEF-2912
4 Likes