Hundreds of features to explore
Games made in Construct
Your questions answered
Popular & trusted by schools and Universities world-wide
Construct 3 runs in the browser & works offline
Students do not need accounts with us
Our educational partners
Free education resources to use in the classroom
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
Can somebody please help me understand the loop functions
I am just trying to create a simple loop
for a = 1 to 10
Have looked in the forum but I am none the wiser
have attached the .capx file, and any help appreciated
You are repeating the loop infinitely, since you added no other condition. If you want the loop to happen once every 1 second, the loop MUST be nested under the Every 1 seconds event. In this case the variable will increase 10 every 1 second.
Bruno thanks for the reply, yes sorry my mistake, but why does it increment by 10 when I do as you suggested.
Do for loops not work the same as in for example Python, where from my above code the loop would count from 1 to 10, using the loop as the counter?
Develop games in your browser. Powerful, performant & highly capable.
Maybe you want to counting from 1 to 10? Then this is what I did:
Because you add 1 every loop iteration. The loop has 10 of those iterations every second, thus, every second it adds 1 to the the variable 10 times. That's why it goes in increments of 10.
Many thanks to you both, I now have a little better idea about loops. Now just to experiment with them!!