How do I know when a function has ended?

Get help using Construct 2

Post » Thu May 22, 2014 10:14 pm

Or maybe a foreach? I have an issue on my project ; a function or a condition is called after a function but this one takes some time to complete, so the next function called fails unless I put a system wait into it (even a wait of 0.0001 second works, but it will fail if I wait 0 second).
I'm pretty sure the problem comes from this, so I'm wondering how I can know when a function or any condition/event has ended. Any idea?
I know I already opened a thread about my issue but my current question is more specific, so that's why I'm creating a new one.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Thu May 22, 2014 10:31 pm

Normally a for each ends like.. this (since Events are read from top to bottom):

Image

And a function is over.. well juts after it's done, I do not know how to explain really, since the function isn't done in parralels, you call the function, it executes it, then it continue where it stopped previously, like if you just pasted the function inside an event (however functions and wait do not mix up that well it seems).
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Thu May 22, 2014 10:43 pm

If it works like this I guess my problem is not what I thought, which means I'm still stuck on this nasty issue. >: ( I have no other system wait of any kind in my events so I really don't understand why my events work the right way only if I use a system wait.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Thu May 22, 2014 11:07 pm

It may be a stupid suggestion, but instead of having the for each inside the function, maybe have it outside, before calling it
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Thu May 22, 2014 11:26 pm

Answer added to initial thread.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494


Return to How do I....?

Who is online

Users browsing this forum: divsyntax, pmerineau and 11 guests