loop + function - weird problem, any ideas?

Get help using Construct 2

Post » Tue Nov 12, 2013 2:27 am

Hey guys.
I've got some weird problem.

I've got events like this:
keyboard "a" pressed : call function "a"

on call "a":
for each element of array XY: call function "b" with 3 parameters

on call "b":
var = 0
- add f.call("c",x,y,z) to var
- add f.call("d",x,y,z) to var
- add f.call("e",x,y,z) to var
- var > 0: return 1
- else: return 0

"c"
- for loop 0-8 with one condition: do something + set return value to 1

"d"
- for loop 0-8 with one condition: do something + set return value to 1

"e"
- for loop 0-8 with one condition: do something + set return value to 1


The array (bolded part) has 9 elements. So it should call b 9 times, but the game just freezes and I get high cpu usage. Okay, you might say that the problem must be some complication with variables (or similar) when calling the function b more than once in a loop.
BUT here is the weird thing: it runs fine if I use "for 1 till 9" as loop. Why could that happen?

I would prefer using the array: for each element XY as it would be more elegant(as I have to iterate over two dimensions). So maybe someone got much experience with loops in loops and has already experienced this and found out why this happens?mindfaQ2013-11-12 02:29:45
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Return to How do I....?

Who is online

Users browsing this forum: ivanski1983 and 13 guests