Getting started with Defold

…aka Big List of Defold Beginner Tips!

Hey all’y’all! We’re constantly trying to improve the user experience for people who want to start using Defold through a number of activities, hoping to lower the threshold for new users getting started with Defold. And I thought that since most of you guys have already passed that critical hurdle, I’ll ask right away – what were the main obstacles you faced when you started using Defold? High and low – everything from the unusuality (is this a real word?) of creating a project outside the editor to too lengthy tutorials. Anything and everything is highly appreciated!

Thanks,
/Axel

2 Likes

The main obstacle I would say was learning how to use and position the camera since most/all of the beginner tutorials given don’t involve a moving camera

2 Likes

Personally I’d say the “message passing” system definitely took a little while to get used to - for someone used to languages like C++, Java, C#, and CoffeeScript (compiles into JS, just with improved syntax) messages can be a little tricky to adjust to at first. The difference between the scene graph arrangement and URL arrangement also takes a while to get used to - this is mentioned in the documentation, but from looking at some forum posts this seems to be something that a decent amount of people aren’t aware of.

2 Likes

This is great – thanks, guys! What about prior to actually getting started with using the engine – any funky business you noticed? Like, website, onboarding or Dashboard-related stuff?

1 Like

I’m on boarding finally now, having freed up the time. My programming skills are quite rusty but I’m managing to get things. I’d say one big help would be more discreet examples - almost unit test in nature. While the API reference helps, they’re not perfect.

So I could imagine a small wiki of micro tutorials for very basic things e.g.:

How to render a single piece of text to the screen wherever you want it to be.

How to move a game object based on the users finger on a screen (or mouse).

How to map 5 sounds to keys or gestures, and play them plus background music that starts/pauses.

I think for beginners there is a tendency to think about “how do I make a platformer” but for me what I want to do is really understand each discreet component in basic cause->effect relationships and just create a thousand “hello worlds” and then I’ll figure out how to bring them together more.

Overall the documentation is pretty good, but having more that is simpler would be better than more larger pieces.

It’s also not easy to find all the property dialog values and what they do. I was just looking for information about the text properties as it relates to the dialog box it shows for a GUI text node and I couldn’t easily find it.

2 Likes

Welcome aboard! I hope you’ll enjoy learning and using Defold! In my mind the manual pages would work very much like micro tutorials, but since I’ve been using Defold for so long I’m probably not the best judge of this. While I currently don’t have the time to write micro tutorials I’ll give you some pointers to solve the problems you’ve mentioned. If you come across more of these “How do I achieve X?” then please post them one by one here as questions and we’ll try to help you out!

How to render a single piece of text to the screen wherever you want it to be
You have two options here:

  1. Post a draw_text message to the renderer. This is mostly for debugging.
  2. Create a gui with a text node

How to move a game object based on the users finger on a screen (or mouse).
This involves a couple of things:

  1. Define input bindings, let a script attached to a game object acquire input focus and detect input in the on_input() function of the same script. All of this is described in the manual on Input.
  2. Once you have managed to detect input you can animate the game object to which the script is attached to using go.animate(".", “position”, go.PLAYBACK_ONCE_FORWARD, vmath.vector3(action.x, action.y, 0), go.EASING_LINEAR, 1.5)

How to map 5 sounds to keys or gestures, and play them plus background music that starts/pauses.
Again, this is a matter of defining, acquiring and detecting input and then performing some kind of action.

  1. Define, acquire and detect input.
  2. Playing sounds should be well described in the Sound manual

Thanks! Some of these I had figured out, just had to piece together different parts. Even then hadn’t seen the draw_text function. Did it with GUI – though need to play with it more. But that’s exactly why having a bit more of these mini-tutorials more specifically documented would be useful.

I’ll play with the others stuff soon too.

One thing I’m dealing with now is factories, and while the documentation explains what they are, and the code related to them pretty well, I am struggling with the UI part. Where do I add a factory and why don’t I see anything listed for prototype…?

So I tried the draw_text feature and put it in the init of a script - the idea being it would draw the text on initialization of that object. However, I get nothing? Does it use a default color? There does not seem to be any other way to change that. Obviously text nodes do have this nicely but I can’t find anything else about how draw_text might or might not work so I can understand it better.

Does draw_text have to be in an update? that seems like overkill given the frequency yes?

Yes, has to be in update. By the way, it’s meant for debugging only not as regular text for your game.

A factory is a component in the same way as a script, sprite, sound or particle fx, meaning that you need to add it to a game object. Right click the go in the Outline and select Add Component and chose Factory. Now you should see a Factory in the outline. Select it and pick the prototype go it should spawn.

I am doing that (or think I am) and here’s what I see…

I suspect it’s a code organization thing - something earlier I’ve done wrong that doesn’t allow the reference to any of my game objects to populate the prototype choice dialog.

Yep I saw that before - best for debugging, so I had focused on the GUI component which I had working before my original post. For sake of argument though, still would like to know how this (or any other functions) work as specific and stripped down as I can. So will play with this some more.

Actually right now about to play with Text GUI objects some more to recreate some things like spoken text from a character, etc. It does seem… like Defold thinks of text more as a GUI object than as an in-game object/canvas. But for those of us who think about having things like spoken character text, etc. we tend to think of things as on-screen text not necessarily a menu or score caption metaphor.

I realize it may not matter in terms of actual functionality but having seen some earlier posts about doing things like attaching text to a game object (so they move together easily) I suspect this disconnect between text for menus, scores, etc. vs. text for more narrative or other gameplay features creates the disconnect.

I can tell you long term you will want to be changing your render script, and maybe making another GUI layer / material that renders closer to how game objects work, and then use this layer for character speech bubble text / gameplay text like damage counters as it will make positioning easier for you. You’ll figure it out. Everything you are talking about is possible and in reasonable ways.

You can only select game object prototypes from game objects which exists on disk (ie New->Game Object file), not the ones you have created in-line in a collection (ie right-clicking in collection and Add Game Object).

I thought this was documented in the Manuals, but I can’t even find a section on factories. @sicher, where have we documented factories?

Thanks! Makes sense. Right now I’m just working with the objects and how to get them to do some things I want. Moving from there to layers for this would be smart. It seems what I would do is just pass some sort of function variable from the code to the GUI layer scripts that then is used to set up on that “speech” layer what I want to render. But that’s a ways a way, still working on a lot of BASICS. :wink:

That was a problem for me as well… there’s lots about factories but it’s spread across other tutorials and so it doesn’t necessarily bring focus… Thanks for the help - will try to get it to work.

So I tried what you said and still not getting anything to populate in the prototype field. I’m going to start a new project and try to see if that helps.

You have a Game Object made outside of the collection? Try to delete the ** too.

This example has a working factory : Big List of Defold Pro Tips!

What if you start typing the name of the game object as it is shown in the Project Explorer? Could you post another screenshot?

So I loaded up @Pkeod project he linked to. That took a bit as I had to figure out how to access local saves, and re-commit using the synchronize. I tried using SourceTree to help but it’s fighting me on my password token (will save that for a different post). So I used the local source control.

I got his Factory example to load and build/run.

I see how Factories must reference a .GO not stored in a collection. That sort of makes sense as these are, I guess, parent objects.

However, I deleted the factory reference in his prototype field which was /main/ghost.go and then opened the … dialog to select it again. No dice. Empty. Remove . Nothing. Typed ghost, nothing, typed ghost.go nothing, Typed /main/ghost.go nothing (OK is still ghosted).

If I go to the field (not the dialog) in the properties and type /main/ghost.go it works. I also typed in other files, and other elements like ghost.go without /main here just to see what would happen and it didn’t work (expected).

So for me it seems if I type the exact resource file location it will populate and work, but if I use the search and select dialog it does not.

I could post screenshots but they’re redundant.