Infinite for loop

Discussion and feedback on Construct 2

Post » Thu Aug 13, 2015 7:32 pm

Message: xangamer is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
Hey Guys,

I am new to construct and facing a very weird issue with the for and foreach loops. They just do not stop. :?

Here is a sample capx with a for loop from 1 to 3. Ideally it should stop at 3 but just keeps repeating itself. An infinite for loop. :oops:

Am I missing something trivial here?

Using the latest stable build (206) on Windows 8.1 and tested on IE, Chrome, FF and Safari

Thanks.
B
5
Posts: 3
Reputation: 231

Post » Thu Aug 13, 2015 7:35 pm

URL to capx was removed due to low rep. www[DOT]dropbox[DOT]com/s/4xtkebcqlqxv67j/for%20loop%20never%20stops.capx?dl=0
B
5
Posts: 3
Reputation: 231

Post » Thu Aug 13, 2015 7:39 pm

your event n°2 runs every tick

Try to use function to run your loop once or just add it as sub event of event n°1
Image Image
B
25
S
14
G
139
Posts: 876
Reputation: 72,510

Post » Thu Aug 13, 2015 7:52 pm

Thanks MadSpy for your help. Was struggling on this for quite a while.

Nowhere is it mentioned that the loops will be repeated in the game loop.
B
5
Posts: 3
Reputation: 231

Post » Thu Aug 13, 2015 8:07 pm

C2 reads all the events every tick https://www.scirra.com/manual/75/how-events-work
Image Image
B
25
S
14
G
139
Posts: 876
Reputation: 72,510


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 18 guests