Page 1 of 1

How do I create a function that takes parameters

PostPosted: Sat Nov 08, 2014 3:37 pm
by hgr
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 :-)

Re: How do I create a function that takes parameters

PostPosted: Sat Nov 08, 2014 3:53 pm
by DuckfaceNinja
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.

Re: How do I create a function that takes parameters

PostPosted: Sat Nov 08, 2014 6:25 pm
by hgr
Ok thanks I figured it out.

Boy I wish I could just write some simple code. :-)