Dynamically Create All Texts(Labels) In Lua Script?

Hi,

We want to create all texts(Labels) for our game dynamically only in Lua scripts.
Is the above possible?
Also do we need one Label for each unique text?
Let us know, thanks!

Jesse
www.FallenAngelSoftware.com

Hi Again,

We want to basically do everything through Lua script code
including drawing backgrounds, drawing sprites, & drawing text.

Is the above possible?
Thanks!

Jesse

Not sure about what you mean with drawing background/sprites.
If you just create a GUI scene with only one textnode on it you can with code clone that textnode and place it anywhere you like, setting any text in it that you want., change the font etc. Still all the resources needed (fonts, materials) need to be provided in that gui-scene.
For sprites, tilemaps etc, there are all possibilities to create and modify these from code via factories.
As I saw you are just starting up with Defold in another thread I also suggest you try a few tutorials out and you will soon have these questions answered for you faster than anyone can reply in this forum.

Good luck
/A

3 Likes

Hi,

Please look at this dev screenshot:

I tried to drag & drop the “FAS-Website.label” text and “FAS-Statue.png” sprite onto the GUI screen rectangle but it’s not working?
What do I do now to get the two above resources to show on the GUI screen rectangle?

Thanks in advance!

Jesse

  1. Add image to project.
  2. Create atlas.
  3. Add image to atlas.
  4. Use the atlas on a gui node (requires adding the atlas to the gui textures list).

I really encourage you to go through a couple of examples, tutorials and documentation. It’s all in there: https://www.defold.com/learn/

1 Like

That is not really how Defold works. You can do it with GUI scripts, but it sounds like you might want to look at some engine that is more like an API that you code against?

Hi,

Thanks for the response.

The documentation is a little confusing…
I can’t figure out this step from above:
4. Use the atlas on a gui node (requires adding the atlas to the gui textures list).

Thank you

Jesse

There arealso video tutorials online: https://www.youtube.com/watch?v=4XGbQ92FzRI&list=PLS9MbmO_ssyC5gN_850U7iz21ZhdjS3J8

1 Like

Read this: https://www.defold.com/manuals/gui/#_textures_and_flip_book_animations

The screenshots are from the old editor, but the differences are mainly looks.

1 Like

You can also go through the “Colorslide” tutorial available in the editor (and here: https://github.com/defold/tutorial-colorslide). It explains the steps involved when building a GUI.

There’s also the GUI examples here: https://www.defold.com/examples/gui/button/
You can find the project with all examples here: https://github.com/defold/examples/

1 Like