For each + Every x seconds [RESOLVED]

Get help using Construct 2

Post » Thu Sep 19, 2013 3:11 pm

Hello everyone,

I think I still don't understand that 'for each' fonction.
I'm trying to make 3 enemy instances fire every 2 seconds.

Here is what I've done :


For each 'EnemyName'
'EnemyName' is onscreen

     -Every 2 seconds      |    Set animation to "Fire"


That is very simple. But only one of the 3 enemies fire. Why? I really don't get it. I try to move and change the configuration of the events, if the "every X seconds" is used, it doesn't work.

Do you have an advice to resolve my issue?

Thanx !KaMiZoTo2013-09-19 15:59:40
B
73
S
21
G
12
Posts: 314
Reputation: 12,148

Post » Thu Sep 19, 2013 3:20 pm

You need it the other way round :

i.e. Every 2 seconds
     For Each EnemyName    Set Animation to Fire

That should work.
B
47
S
18
G
84
Posts: 2,271
Reputation: 49,796

Post » Thu Sep 19, 2013 3:21 pm

+ Every 2 seconds
++ for each EnemyName
+++ Enemy is on screen
---> EnemyName set animation to fire

;) or you do it with wait


Edit: Damn plinkie :D Darklinki2013-09-19 15:21:49
B
15
S
6
G
6
Posts: 512
Reputation: 5,555

Post » Thu Sep 19, 2013 3:22 pm

@Darklinki
haha nice!
B
47
S
18
G
84
Posts: 2,271
Reputation: 49,796

Post » Thu Sep 19, 2013 3:34 pm

Why do you need for each?
Image ImageImage
B
172
S
50
G
183
Posts: 8,442
Reputation: 115,603

Post » Thu Sep 19, 2013 3:42 pm

@newt
True.
B
47
S
18
G
84
Posts: 2,271
Reputation: 49,796

Post » Thu Sep 19, 2013 3:43 pm

Spot the pro @newt

If add enemies as a family you don't need for each do you?
Just use enemyfamily
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,728

Post » Thu Sep 19, 2013 3:45 pm

You don't need a ForEach even if it's not in a family. You can just do Every 2 seconds > Sprite Set Animation "Fire" if it was just a Sprite object. There could still be a reason that he's using ForEach though maybe, who knows!
B
47
S
18
G
84
Posts: 2,271
Reputation: 49,796

Post » Thu Sep 19, 2013 3:47 pm

Thank you that work!
I wanted to use the 'every X seconds' after the 'each' in order to use a random time (every (random(1,2) seconds) so they don't fire at the same time.
But I can just use a random wait action instead.

@Newt I need the 'each' because they also fire bullet from their gun.

Thanx again!!
B
73
S
21
G
12
Posts: 314
Reputation: 12,148

Post » Thu Sep 19, 2013 3:50 pm

@plinkie, really, I've been doing it all wrong then lol.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,728

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests