How to Update function param value ?

  • Hi,

       I need to make a common function which would set X,Y properties of any object passed to it.

    ex: function hideObject :(Action) Set Function.Param(0).X to -100

                             (Action) Set Function.Param(0).Y to -100

    I am not able to find any way in which I can access & set function param values in actions, I can only see System 0> Set Value of variables not Object.variable ?

    Your help would be highly appreciated...

    -Thanks

  • do you mean "call function xxxxx" with a specific param

    in the dialog box of "call function" there is a "add parameter" or something like that below

  • You'd put the objects in a family and pass the object's UID to the function. Then in the function have:

    Family: Pick by UID Function.Param(0)
       -> Family: Set X to -100
       -> Family: Set Y to -100
    
  • ramones would it be possible to provide a sample capx, I am actually confused in making this work in C2 cause I did not find any arbitrary variable setter action.

    -Thanks

  • mchulet   

    I was just wrestling with this myself and figured out how it works:

    Whenever you call the function, add the new parameter into the parenthesis. Here would be an example in the Event sheet:

    SYSTEM --> On start of layout --> Function --> Call "nameOfYourFunction?(7)

    Then to change it on the next use would be:

    SYSTEM --> On start of layout --> Function --> Call "nameOfYourFunction?(559)

  • Example: hideObjectFunction.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks ramones

    ramones Thanks for the example, but if you look at it this function hideObject gets tied for a specific Sprite object. What I want to do is call hideObject for any Sprite. Also want to void checking in the function which sprite this function has been called on.

    Something like:

    SpriteA -> Call hideFunction(IID)

    SpriteB -> Call hideFunction(IID)

    SpriteC -> Call hideFunction(IID)

    In hideFunction

    Function.Param(0).X = -100;

    Function.Param(0).Y = -100;

    -Thanks

  • I'm not sure what you mean. In the example it will work for any object in the Sprites family. It works like this as well:

    <img src="https://dl.dropbox.com/u/8367729/construct/pics/hideObject.PNG" border="0" />

  • ramones sorry I overlooked that you had used Families to combine all Sprites in the project.

    -Thanks

    Mahesh

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