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
62
S
20
G
57
Posts: 1,077
Reputation: 36,531

Post » Thu Jan 12, 2017 9:43 pm

You pass the UID into the function, and then Pick by UID first.
ImageImageImage
B
72
S
22
G
288
Posts: 3,862
Reputation: 158,460

Post » Thu Jan 12, 2017 9:50 pm

@blackhornet I'm not sure how to do that correctly.
B
62
S
20
G
57
Posts: 1,077
Reputation: 36,531

Post » Thu Jan 12, 2017 10:03 pm

ImageImageImage
B
72
S
22
G
288
Posts: 3,862
Reputation: 158,460

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
62
S
20
G
57
Posts: 1,077
Reputation: 36,531


Return to How do I....?

Who is online

Users browsing this forum: Diamond Dino 64, mallorcaredes, PitfallJerry and 4 guests