How do I create a function that takes parameters

Get help using Construct 2

Post » Sat Nov 08, 2014 3:37 pm

Hi.

I am completely new to construct 2, and I am a "classic" developer that usually writes code, so I have a hard time trying to understand construct 2.

I need to set the opacity of the mouse cursor, dependent on some condition in the game.

So I decided to create a function that would change the mousecursor sprite, but adjust the opacity of the sprite before doing so.

This function needs to take a parameter telling it if it should increase or decrease the opacity.

But how do you create a function that takes a parameter, and how do you access the parameters within the function?

The manual mentions that a function can take a parameter, but does not give an example of how you actually create such a function.

The old dude is a little confused :-)
B
5
S
1
Posts: 59
Reputation: 493

Post » Sat Nov 08, 2014 3:53 pm

You can add parameter through [Action: Call Function]. Just click "Add Parameter" to add parameter. In the function, you can take the parameter by index such as Function.param(#index).

There are some screenshot at tutorial page as far as I remember, it's more intuitive to look at pictures.
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Sat Nov 08, 2014 6:25 pm

Ok thanks I figured it out.

Boy I wish I could just write some simple code. :-)
B
5
S
1
Posts: 59
Reputation: 493


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 51 guests