Hello.
Coming from Unity, i like DEFOLD very much ! Because its lean, super fast, easy to use, no struggle by exporting / publishing to different systems ! (Allways a nightmare with other gameEngines). Anyways, back to topic: “easy to use”:
I am a real beginner here. Just want to learn the basics. I have a simple scene, the starter Scene with the Defold-Logo. In my main.collection i have on top of the hiearchy a “go”-element. Inside this “go” there is “background” & “logo” element. So i just want to access these child-elements by iD or URL. I have to say, i don´t know whats the difference with these two. So i try to access them by this code:
go.animate("#logo", “position.y”, go.PLAYBACK_LOOP_PINGPONG, pos.y + 300, go.EASING_INOUTSINE, 3)
But it doesn´t work ! If i change the code, especially in the brackets “#logo” to “.” it works, but it moves the whole “go”-element with their child elements. How can i move just the “logo” sprite, instead the whole “go”-element ?
This also don´t work:
go.set_position("#logo", “position.x”, 222)
But this works again:
msg.post("#logo", “disable”)
I am a bit irritated. I didn´t found any tutorials / explainations about how to access child-elements inside a “go”-parent element. Would be great if someone can give me a hint, a link, or a solution to my prob. Thx.
Well, you are accessing the child elements.
Note that only game objects have a transform, so you cannot move a sprite component at runtime.
Game objects are cheap, so you can create a hierarchy of them if you need to have different parts move around.
1 Like
Aha, ok. Good to know. Thx for the fast reply. So i can keep in mind, that it isn´t a good idea to transform “child-elements” inside the “go” (gameObject). Because of performance. Will try it out 
Works perfect, now ! 
The more i play around with LUA, the more i got a better understanding of how it works. I attached my version of the the “Desktop - template”, so it may helps some other newbs:
function init(self)
msg.post(".", "acquire_input_focus")
go.set("logo", "position.y", 100) -- a way to set position ... linear mode
--local vec = vmath.vector3(640, 360, 0) -- defines vec3 position (needed for set "position")
--go.set("logo", "position", vec) -- sets new position of gameObject "logo"
end
function on_input(self, action_id, action)
if action_id == hash("click") and action.pressed then -- take a look inside "input" -> "game.input_binding", ACTION = click
print("Click!") -- console info
local dummy = go.get_id("logo") -- relative path // or : go.get_id("/my_sub_collection/my_instance") -- absolute path
local pos = go.get_position("logo") -- uses "actual" position from go "logo"
go.animate(dummy, "position.y", go.PLAYBACK_LOOP_PINGPONG, pos.y + 520, go.EASING_INOUTSINE, 3) -- uses a "local"-variable
--go.animate("logo", "position.y", go.PLAYBACK_LOOP_PINGPONG, pos.y + 520, go.EASING_INOUTSINE, 3) -- uses a direct "name" id : "logo"
--msg.post("logo#logo_sprite", "disable") -- disbling child-element "logo_sprite"
end
end
My hierarchy inside the main.collection looks like this :
| --> collection
. . |-> _my_scripts (here i put all my scripts inside)
. . |-> background (includes a sprite element “background_sprite”)
. . |-> logo (includes a sprite element “logo_sprite”)
Now it makes more fun than Unity 