Using Defold for a simple serious game

Hello,

I’d like to use Defold to make a serious game for my company.

The goal is to review some procedures.
For this, the user will have to read some text on a virtual sheet, and he will have to click on pertinents elements (given in the game instructions).

But i wonder how to present those elements.
I’ve eliminated the idea to display a picture, and store a table with virtual coordinates (starting from origin of the picture, and scaled with the resolution displayed). I would have to present pre-rendered pictures, and browsed them for getting pertinents coordinates: AAARRGH !

I’m thinking about using a GUI, and rendering generated text (for introducing some variations).
Then, under some elements of text, i could generate an invisible button and the click on it could be counted as a good answer (and then coloring the button for highlighting the good answer).
That mean Defold would interpret a text with some “orders” in it (like “there is a button beginning/finishing here”). Then i will have to generate the elements, give the font size and the text position.
What do you think of this approach ? If this is good, can i do it with plain defold gui elements, or should i use a GUI module ?

Thank you for reading.

Hi! I have somewhat limited Defold experience but I think you don’t have to use a hidden button under text GUI elements. You can use GUI text nodes and use function gui.pick_node(node, x, y) to see if a click at position (x, y) is a click on node “node”. I believe text nodes behave the same as boxes, at least the documentation mentions the function works for the “node bounding box”.

So with that function, when you register a click, you can have a table containing a list of text nodes urls and loop through the table to see if you hit one of the good text node. You can then message the node and change the text color for example. You can too use a box under, mind you, if you wish to color the background of the text node, but you are not forced to. And perhaps this is even possible directly with some text node property. You would have to check!

Also one thing I’m pretty sure of is that gui nodes can be used on their own. Defold has some GUI assets (libraries) you might want to check. They facilitate working with UI. They are not mandatory but helpful. I have yet to use them - the UI in my game is basic so far - but you might want to explore their use!

Hope this is helpful!

1 Like

Yes that’s useful, thank you. Now i have an idea from where to begin.

I will update here with my progresses.

1 Like

Ok! Good luck and don’t hesitate if you have other questions!

1 Like

Some issues you would need to work out would be your text metrics for the generated text, that way you know where and how big of a button to create for the text. Now if your generated text could be prefabbed you could place all the buttons beforehand.

1 Like