For Loop Not Working Correctly

Just started using Construct 2? Post your questions here

Post » Thu Apr 28, 2016 10:49 pm

Can someone explain why my loopIndex inside my for loop is jumping from 0 to the end index?

I have a set up similar to this
global test = 0
-if Hud_Bar_Shield.count == 0
--for(start=0,end=10)
--- set global test to loop index
---create Hud_Bar_Shield(L=3,X=(Hud_bottom.x+11)+(Hud_barShield.Space*loopindex("ShieldLoop")),Y=Hud_bottom.y+14)
---add instance var(Index loopindex("ShieldLoop"))

basically I'm trying to make a megaman x style life bar with objects
B
14
S
6
G
1
Posts: 150
Reputation: 1,987

Post » Thu Apr 28, 2016 11:10 pm

We need to see the real code. You are interchanging loopindex and loopindex("ShieldLoop")
Last edited by blackhornet on Fri Apr 29, 2016 12:25 am, edited 1 time in total.
ImageImageImage
B
71
S
22
G
259
Posts: 3,794
Reputation: 143,704

Post » Thu Apr 28, 2016 11:53 pm

B
14
S
6
G
1
Posts: 150
Reputation: 1,987

Post » Fri Apr 29, 2016 12:41 am

Sorry, that doesn't help. It looks fine. What is Table_Player? Try isolating the code into a separate project and experimenting, or post CAPX.
ImageImageImage
B
71
S
22
G
259
Posts: 3,794
Reputation: 143,704

Post » Fri Apr 29, 2016 11:36 am

Do you mean that, if you run it in the debugging mode, the variable loopindextest is either =zero or =the end of the loop ?

Well, yes, it happens in 1 tick. You dont see that loop counting, its is done in less then a blink of an eye. So it or zero, when the condition is not met, or the end of the index when you look at it. It is Schrödinger's cat.

If it does not loop (from zero to end), then you really need to upload the capx. But, i expect it to loop because you basecaly say that the variable does indeed show the end of the index.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests