Possible missing documentation?

Hello there,

I’m hoping someone can help me understand what may be possible documentation missing for the Defold API.

I was trying to figure out how I can hide label within a one of my game objects. Looking at the label api it doesn’t seem to have any ability to hide it per the Defold docs.

But I did try doing this: msg.post("#label", "disable")

And this ^ above works.

Can someone point me to documentation that shows this API call and others like it that work? I suppose i’m also confused why some manipulation happens with: go.set() vs label.set_text() vs msg.post("#label", "disable")

None of this is intended to critisize this wonderful engine but more of just seeking guidance on when to use the different style API calls and where some of the documentation might be missing or incomplete.

Thanks!

-deckarep

The “enable” and “disable” messages, which work for most components, are documented in the base Game Object API doc, here: API reference (go)

I agree that this doesn’t help very much when you’re looking for how to disable a specific component, as would often be the case, though I’m not sure what the best solution for that would be. Maybe links could be added to the component pages to their “inherited” messages (though those may be the only two).

Okay, that is helpful.

Do you @ross.grams happen to know if there is an inheritance chain published anywhere so I can see that a Sprite inherits from game object assuming that is an accurate statement?

1 Like

Ah, no. I put “inherited” in quotes because I am quite sure it doesn’t work that way. Components are placed on game objects, they are not game objects themselves. I don’t think there is any OOP-style inheritance like that in Defold.

1 Like

Ok, that makes sense and thanks for the help today!

1 Like

Correct. There’s no OOP inheritance going on. Game objects in Defold are by default empty “containers” with a transform (position, rotation and scale). You can attach one game object to another so that the child game object inherits the transform of the parent.

Game objects become something useful when you add components to them. Components can be sprites, labels, scripts, sounds etc.

Side-note: In the editor and the data files there is also a concept of collections. A collection is a way for you to organise groups/collections of game objects. These groups of game objects can be spawned using factories or loaded and unloaded when needed. The collections themselves do not exists in runtime. It’s only the game objects that are there.

Learn more here: The building blocks of Defold

2 Likes

Thanks you for the additional context here @britzl! This definitely helps to solidify my understanding of the mechanics of Defold.

1 Like