Nested For loops not seems to work as expected

Get help using Construct 2

Post » Mon May 06, 2013 8:37 pm

I have a for loop wrapped around another for loop, the inner loop seems to iterate only for the number of iterations set on the outerloop, Please help

B
16
S
4
Posts: 248
Reputation: 2,267

Post » Mon May 06, 2013 9:13 pm

Your second loop is 'for each' loop, which runs for each picked instance of 'PImage'. Not sure what you are trying to achieve there, but in the visible events you are not picking any 'PImages', so it probably does not do what you want. Instead it runs on every single instance of PImage every loop round.

B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Mon May 06, 2013 9:17 pm

I'm not sure, but this could be caused by the difference of For and ForEach.

Your outer loop is a For loop. With start and end based on parameters.
Your inner loop is a Each loop. Where a loopindex might not be required as your itterating through the objects anyways. There might be able to find your loopindex another way.

Just a thought of course.

edit: vee beat me to the post button :Djayderyu2013-05-06 21:18:12
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Mon May 06, 2013 9:18 pm

tringio,

Maybe you can help us giving more information about what you want achieve with this.
ImageImageImageImageImageImage
B
93
S
19
G
12
Posts: 1,192
Reputation: 18,301

Post » Mon May 06, 2013 9:25 pm

I hop i am not confusing others, ok this is what i need, i have a Sprite which has an instance variable to stored the UID's of other similar Sprites called DuplicateUIDS in the form of CSV's. (e.g) Sprite.DuplicateUIDS="1001,1002,".

So i basically get the Sprite , get it's DuplicateUIDS , and for each DuplicateUID i need tfind the corresposding Sprite and do some action on them, which is what i am doing , instead this is the output i am getting, also i have about 27 Sprites


PImage.DuplicateUIDS230,
DUP UID = 230 , 0
PImage Count 27
PImageLoop = 0
Finding Duplicates PImage.UID = 228
Duplicate instance picked .... 230
DUP UID = NaN , 1
PImage Count 27
PImageLoop = 0
Finding Duplicates PImage.UID = 228
Duplicate instance picked .... NaN

Please advise.
B
16
S
4
Posts: 248
Reputation: 2,267

Post » Mon May 06, 2013 11:36 pm

any one ? feels simple but doesn't seem to work
B
16
S
4
Posts: 248
Reputation: 2,267

Post » Tue May 07, 2013 6:42 am

Replace your for each- loop with 'pick by UID: tokenat(PImage.DuplicateUIDS, loopIndex, ","). You might need to add 'pick all' condition before it, depending wheter you have picked PImages previously.

You'll also need to save your PImage posx/y to local variables, as you'll be referring to the newly picked PImage instead of the 'original' one.

Posting a capx would help, don't really see the need for nested loops here :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Mon May 27, 2013 9:26 am

Hi,

I am new and still trying out Construct 2.   I am trying to create an end-less loop with elements in an Array.

Each array element needs to Pause for about 45 seconds, so that the visitor(s) can see WHAT they are. ..

I am not sure how to do a "While True" statement and insert the delay of 45 seconds when retrieving the value of the Array for display.

The reference link is below:

http://www.leiron.be/exttopics3/array/array-testing.capx

I am actually trying to Re-Do a similar animation i had done lately which is below :

http://www.leiron.be/exttopics3/tc/

Please help and thank you.

I am actually hoping to find a better alternative or a more flexible tool for me to do both Animation and Simple Games.

Kind Regards.

Vins

B
5
S
1
Posts: 20
Reputation: 545

Post » Mon May 27, 2013 6:15 pm

@vinsky2007 I think this is what you want: loopThroughArray.capx (r132)
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,000

Post » Tue May 28, 2013 4:04 am

Ramones,

Hi and Thank you very much for the much support you have extended to me and YES, that is what i have in mind.

Thank you, Thank you, Thank you.

Vins
B
5
S
1
Posts: 20
Reputation: 545

Next

Return to How do I....?

Who is online

Users browsing this forum: Bad Wolf, davides, NRABrazil, Vallar, WhosWho and 32 guests