[Solved] How do I make function with object parameter ?

Get help using Construct 2

Post » Sat Mar 15, 2014 1:18 pm

Hello everyone,

I want to know if it's possible to make a function which can take an object in parameters.

Lest me explain, in my game I have sprite objects ('Player1', 'Player2', ...), with an array container ('Player1Array', 'Player2Array', ...). This array is an historic of player's positions (Player1.X, Player1.Y, Player1.Angle).
My game has several steps :
1 - You control Player1 and the game record his movement.
2 - You control Player2 (and the game record his movement). The game move Player1 by reading Player1Array.
3 - You control Player3 (and the game record his movement). The game move Player1 by reading Player1Array and Player2 by reading Player2Array .
4 - ...

The record method is the same for all player objects, but not use at the same moment.
I want to make a fonction to record player but I not be able to specify which player is concerned.

Do you have solution for me ? :roll:
Last edited by TimDark on Sun Mar 16, 2014 3:28 pm, edited 1 time in total.
B
6
S
1
G
1
Posts: 7
Reputation: 439

Post » Sat Mar 15, 2014 1:31 pm

Pass the UID of the object and then 'pick by UID' in the function.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,670

Post » Sat Mar 15, 2014 11:26 pm

Thanks for your answer, but I don't know how can I use the pick by UID ...
I find a pick by UID, but it's for condition, and me, I will use the UID like : UID Set value at (X, Y) to 1, if I pass an array's UID.
B
6
S
1
G
1
Posts: 7
Reputation: 439

Post » Sun Mar 16, 2014 2:36 pm

If your different players/arrays can be instances of the same object then you can pass the player UID and use it like this:
passUIDToFunction.PNG


If you need separate objects for each player I'd say it might be easier to not use containers and just spawn a separate array instance for each player:
spawnArrayForEachPlayer.PNG
You do not have the required permissions to view the files attached to this post.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,670

Post » Sun Mar 16, 2014 3:26 pm

Thank you ramones !

I think this problem is now over.
B
6
S
1
G
1
Posts: 7
Reputation: 439


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 9 guests