How do I convert a group of events into a function?

Get help using Construct 2

Post » Fri May 27, 2016 8:27 pm

Hi, I have a group of events I need to do many times and I only need to change a few parameters, I'd like to know how to make this into a function with parameters, I can't seem to grasp it. I'm thinking this can be done?

I highlighted in blue the things that will need to change in the function.

Image

Thanks in advance.
B
22
S
12
G
19
Posts: 54
Reputation: 11,554

Post » Fri May 27, 2016 9:08 pm

Roughly you want to pass in the two UIDs of the objects so they can be picked again, and then move events 409-412 into the function. I like to pull the params out into variables, but that isn't necessary. I think it's cleaner though. The "for each" is in case the weapon hits more than one enemy at a time.

Image
ImageImageImage
B
71
S
22
G
249
Posts: 3,762
Reputation: 138,575

Post » Fri May 27, 2016 10:41 pm

Ok, I see! Thanks!
Can I also add another param(2) for the missile_1.dmg for events 409 and 410?

edit: I saw a lot of tutorials on functions but they really didn't explain them with parameters.
B
22
S
12
G
19
Posts: 54
Reputation: 11,554

Post » Fri May 27, 2016 10:46 pm

Yes, if that needs to change. It wasn't clear where Missle_1 came from, since it isn't directly referenced in the picked objects.
ImageImageImage
B
71
S
22
G
249
Posts: 3,762
Reputation: 138,575

Post » Fri May 27, 2016 11:49 pm

Ah ok thanks!
Missile_1 is a sprite instance variable I keep the damage of each weapon in.
B
22
S
12
G
19
Posts: 54
Reputation: 11,554


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests