#For Loop goes faster
35 messages · Page 1 of 1 (latest)
When there are multiple elements in an array, it updates faster, as seen by the example Gifs.
Your code doesn't really tell me enough to say exactly what's happening. But with 10 items in the array you're gonna call update 10 times, if there's only 1 item you only call update once.
Yeah, and is there anyway to seperately update each one?
No idea. You would need to share more code.
No idea. It's your code and I haven't seen it.
It's really just the W3School Flappy Bird example code.
No idea what that is or where to find it.
I don't see why any of that code would be sped up by adding more components. It already adds new components over and over.
Did you change anything else?
When I got rid of myObstacles[i].x += -1;, it started going faster
forgot to mention, I have my own moving part, but that's not what is making it faster.
I debugged it, and it is the for loop that is making it faster
What else did you change?
I believe that's it
So the gifs are the result of changing that one line?
I got rid of the line, I have my seperate moving system, but what I believe the problem is that it is being updated faster.
So my question is if there is any way to slow them down
Ok, so you did change stuff. I can get rid of that one line too and nothing goes faster.
So some other change you made is causing things to go faster when you remove that one line.
The line makes it move by itself, however that's not what I want anyway.
I don't know because I don't know what changes you made that would cause it to go faster.
Makes what move by itself?
The line makes the component move by itself, my code makes it so you choose where it goes, that is not the problem though, I debugged the code manually and found out that the for loop is the problem.
The components are the green lines in the W3C code. You don't have the green lines so I'm not sure what's moving by itself.
Again, removing that line from the W3C code doesn't result in a speed up for me. Therefore some other change you made must be causing the speed up when that line is removed.
Sorry. I can't help if I can't replicate the issue. No one would be able to help you given the information you have shared thus far.