How do I add parameters to a function I create?

0 favourites
  • 4 posts
From the Asset Store
Customize the animation of character when item changed
  • I see various tutorials for functions but they seem a bit beyond my reach for understanding how to add my own parameters to a function.

    For example, I'd like to be able to create a text object and set its text to whatever I want by using a function like this:

    Function SetText("Hello World",0,5)

    So "Hello World" is Parameter(0), x-coord is Parameter(1), and y-coord is Parameter(2). But when I've created functions for use in my game I don't know how to go about doing the parameter parts. My functions just end up being "do this, now do that" routines instead of "do [this], now do [that]" which is what I'd like to do instead.

    I hope this makes sense.

  • When you call a function you can add parameters. Then in your function use the system expression Function.param(x).

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You dont need to set the params when you create the function.

    When you call a function theres a button below the textbox where you write the function name, called "Add parameter".

    So you will do something like this:

    Function > Call "setTextFunc"(txt, X, Y) ....you will need to add 3 parameters here

    Function > On "setTextFunc" > TextBox > Set text to "Function.Param(0)

    TextBox > Set position to (Function.Param(1), Function.Param(2)

  • Thank you caiorosisca and Joskin for your replies on this! This makes much more sense to me, I appreciate you explaining it out in an example like this.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)