How do I use different variables values in function calls?

Get help using Construct 2

Post » Fri Jun 16, 2017 4:15 pm

I have function spawnEnemies that I use to spawn a wave of enemies. I passing some wave metadata like X, Y, wave size, angle as function params and store it in the local variables. I have to store it in local variables because I use these values in the For Loop. In the loop, I can't access to Function.Param(x).
Basically, it works well until I call two or more spawnEnemies functions at the same time. In that case, the second call overrides local variables and enemies from the first call will have params from second.
Is there a way to "lock" values in the function calls?
Or may another suggest to handle it?
Image
B
7
S
2
Posts: 3
Reputation: 498

Post » Fri Jun 16, 2017 4:38 pm

The problem stems from the "wait" action you have in there. If I were you, I'd ditch it altogether and create the sprites in a single tick, and deal with the delay with a timer. "Disable" the enemy on creation, and "enable" it with a timer set on creation.
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Fri Jun 16, 2017 4:55 pm

Nice trick! Work well for me.
Huge thanks!
B
7
S
2
Posts: 3
Reputation: 498


Return to How do I....?

Who is online

Users browsing this forum: jorgmaquoi, SignalOne and 17 guests