Looping through instances with local variables

Get help using Construct 2

Post » Mon Nov 26, 2012 6:43 am

I'm trying to loop through all instances of an object. If I create the variable changeTextLoop as a global variable, it loops correctly. However, if I create it as a local variable under the testResetLoop group, it doesn't loop. Could someone tell me why this is? A sample capx is below.

Change multiple text objects.capx
B
12
S
3
G
4
Posts: 55
Reputation: 3,186

Post » Mon Nov 26, 2012 6:37 pm

i think this is a better way of doing this

using for loop, loopindex, for each

example
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Mon Nov 26, 2012 6:49 pm

Local variables are reset every tick. You'd need to set it to static for it to keep it's value.
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Fri Nov 30, 2012 6:15 am

Thanks for the help. I didn't know local vars were reset every loop.
B
12
S
3
G
4
Posts: 55
Reputation: 3,186


Return to How do I....?

Who is online

Users browsing this forum: Zebbi and 23 guests