How do I use for each with function.

Get help using Construct 2

Post » Thu Jan 12, 2017 9:40 pm

I want to do something like this, but it's not working as expected:

Function On "Damage"
sprite -> Subtract 1 from health
System -> Create object Explosion on layer "game" at (100,100)
etc...

For each sprite -> Call function Damage

When I try to do it with a function like above it doesn't pick the correct sprites.

I can put the actions in without using a function and it works correctly.

For example, this works:

For each sprite ->
sprite -> Subtract 1 from health
System -> Create object Explosion on layer "game" at (100,100)
etc...
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,991

Post » Thu Jan 12, 2017 9:43 pm

You pass the UID into the function, and then Pick by UID first.
ImageImageImage
B
71
S
22
G
247
Posts: 3,756
Reputation: 137,558

Post » Thu Jan 12, 2017 9:50 pm

@blackhornet I'm not sure how to do that correctly.
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,991

Post » Thu Jan 12, 2017 10:03 pm

ImageImageImage
B
71
S
22
G
247
Posts: 3,756
Reputation: 137,558

Post » Thu Jan 12, 2017 10:29 pm

@blackhornet Thank you, after several tries I was able to get it to work correctly in my code. I don't think I would have been able to get that sorted without your help.
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,991


Return to How do I....?

Who is online

Users browsing this forum: Eren, koops and 7 guests