Stop loop

Get help using Construct 2

Post » Sat Jan 14, 2012 6:23 am

Hi!
How can i stop or exit a loop?
I tried it with Stop loop but it doesnt working.

Thx!
B
19
S
3
G
5
Posts: 98
Reputation: 4,647

Post » Sat Jan 14, 2012 6:39 am

How about a global variable? And when you want to get out of the loop you can change the variable by some kind of trigger.

Do you know what I mean?
B
17
S
4
G
4
Posts: 94
Reputation: 3,058

Post » Sat Jan 14, 2012 9:03 am

no sorry
B
19
S
3
G
5
Posts: 98
Reputation: 4,647

Post » Sat Jan 14, 2012 11:25 am

Okay I'll try again =)

You have a loop with the condition "Global variable loop = 1" .. when you (for example) press X the variable "loop" will become 0 .. so the loop stops.
B
17
S
4
G
4
Posts: 94
Reputation: 3,058

Post » Sat Jan 14, 2012 11:42 am

ill try it.
thx!
B
19
S
3
G
5
Posts: 98
Reputation: 4,647

Post » Sat Jan 14, 2012 12:19 pm

'Stop loop' should work correctly. Can you post a .capx of it not working? It will finish the current event though, it won't break immediately.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Mon Jan 16, 2012 7:34 am

B
19
S
3
G
5
Posts: 98
Reputation: 4,647

Post » Mon Jan 16, 2012 7:39 am

Stop loop works.

The problem comes from the fact that your for loop will run every tick as you haven't filtered it otherwise. (reference: how events work)

If what you're looking for is to make it run once, don't use stop loop, make your for loop a sub event of a start of layout event. It will only run once on start of the layout.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Mon Jan 16, 2012 8:43 am

can u make an example for it plz?
B
19
S
3
G
5
Posts: 98
Reputation: 4,647

Post » Mon Jan 16, 2012 9:21 am

New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Next

Return to How do I....?

Who is online

Users browsing this forum: jobel, Timedoor Indones, Yahoo [Bot] and 21 guests