How to Update function param value ?

Discussion and feedback on Construct 2

Post » Sat Feb 23, 2013 7:05 am

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
B
10
S
3
Posts: 69
Reputation: 1,590

Post » Sat Feb 23, 2013 12:14 pm

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
Image
B
42
S
11
G
5
Posts: 269
Reputation: 10,790

Post » Sat Feb 23, 2013 12:21 pm

You'd put the objects in a family and pass the object's UID to the function. Then in the function have:
[code]
Family: Pick by UID Function.Param(0)
   -> Family: Set X to -100
   -> Family: Set Y to -100
[/code]
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,000

Post » Tue Feb 26, 2013 7:47 pm

@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
B
10
S
3
Posts: 69
Reputation: 1,590

Post » Tue Feb 26, 2013 9:42 pm

@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)
B
13
S
2
Posts: 30
Reputation: 1,272

Post » Wed Feb 27, 2013 12:31 am

B
54
S
28
G
18
Posts: 1,520
Reputation: 25,000

Post » Wed Feb 27, 2013 5:31 am

Thanks @ramones @evilDan.

@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
B
10
S
3
Posts: 69
Reputation: 1,590

Post » Wed Feb 27, 2013 12:14 pm

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:
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,000

Post » Thu Feb 28, 2013 8:14 am

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

-Thanks
Mahesh
B
10
S
3
Posts: 69
Reputation: 1,590


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 10 guests