Does Defold Have A Main Loop Script Like C++?

Hi,

I created a new Defold game project.
I don’t see a “main” script?
Coming from C++ so am a little confused.
Is there a tutorial somewhere which shows how to make a main script/loop?
Thanks!

Jesse
www.FallenAngelSoftware.com

Theres no single main loop, but a main collection.
To this collection you can add one or more scripts. Inside that script, you have an update function.

We have many tutorials online, or you could start off by using one of the tutorials when you start the editor.

Hi,

Ok, I added a new script called “main.script” to “main”.
Will the new “main.script” be run every frame?
Thanks!

Jesse

Yes. I suggest you glance through the manuals at least once. It’s the fastest way to see what’s there and a brief on how it works. E.g. https://www.defold.com/manuals/application-lifecycle/

1 Like

Ok…

Adding a file “main.script” to the folder “main” does not make it run. You should open the bootstrap main collection (usually “/main/main.collection”, but you can change that), add a game object and then add the script as a script component to the game object. Then it will run according to the lifecycle.

1 Like

You can check out some simple examples here as well: https://www.defold.com/examples/input/move/

1 Like

Hi,

Having issues, please look at this screenshot:

I added a game object & script to the main.collection, but both are not listed in main.collection’s dependencies list?

Perhaps I did it wrong?

Jesse

What does the outline contain?

Sorry, this is not going well…
What you mean: “outline”?
I’ve looked at the docs and the sample, but still am stuck on displaying a sprite and text.

Jesse

It’s the part of the editor that says ”Outline”.

it’s empty

Then you have not added anything to the ”main.collection” file.

Have you done any of the tutorials?

1 Like

Hi Jesse!

I’ve read through a few of the questions you posted here on the forums, and while I in every way encourage you to ask questions when you get stuck - after all, that’s what we are here for! - it seems that you might be trying to jump in the deep end of the pool a little bit quickly, and trying too many things at once, based on your questions and your replies to the people who have posted solutions for your problems.

I can highly recommend starting out with the first tutorial, side scroller. This will teach you about a lot of the basics of how Defold works, and begin to change your way of thinking from (what I believe you are coming from) C++ and more in line with Lua and the Defold workflow. When you want to go into GUI’s, Colorslide provides an excellent guide, and the Astronaut tutorial - accessible through the editor - will teach you about input and movement.

After those tutorials, you should be in a good spot to check out some of the more advanced tutorials, accessible in the documentation. If at any point you get stuck while doing these tutorials, or anything else, feel free to post more questions here, and we’ll make sure to help you answer them!

7 Likes

Looks like your outline panel is almost entirely collapsed, drag the splitter (dark line) to expand it :slight_smile:

3 Likes

This is what yours look like:

This is how I would expect it to look:

Ignore the contents of the above screenshot. I’m only posting it to show how an expanded Outline should look like in general. Yours should contain the main script you mentioned.

That was it - seems like a IDE display bug on Linux?
(on fresh start the Outline display is not shown properly)

Anyone know why I can’t scale the image on screen?

Jesse

1 Like

Is that script attached to the same game object as the sprite?

Please show the expanded outline of your main collection, that will reveal how you have set up your game objects and components.

You are trying to scale the component FAS-Statue.png. This might not be the name of the component.

Are you getting any error messages in the console? You do not have it open, but you can open it by going to View->Show Console.

IDE Editor has these display issues on Linux as shown above…

How do I get the name of a Sprite?

Jesse