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

0 favourites
  • 5 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • 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 ?

  • Pass the UID of the object and then 'pick by UID' in the function.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

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

    [attachment=2:2wgceiar][/attachment:2wgceiar]

    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:

    [attachment=1:2wgceiar][/attachment:2wgceiar]

  • Thank you ramones !

    I think this problem is now over.

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