SOLVED - How do I pass an object to a function?

0 favourites
  • 8 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I'm trying to make a simple function that will let me show pop-up text when my mouse moves over an object.

    For this example, I have three objects: Blue, Green, and Red and they are all in the family PopUps.

    When MouseOver on the family PopUps is true it calls the function: PopUp

    Inside that function PopUp, I need to know which of the three objects the mouse over when the function was triggered and I'm not sure how to pass that information into the function.

    Thanks for any help.

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can use ObjectTypeName to pick out the object name but it kinda defeats the purpose of using a Family.

    If your individual object does something on its own then just say mouse over that object instead of family.

  • Thanks, but I'm still not sure how to use ObjectTypeName in the Function. Here is the sample code:

    If I don't use the function (seen in this first shot) it references the correct object correctly:

    If I do use the function (seen in this second shot) it doesn't work:

    What I ultimately want to do is much more complicated than this one line function, so I definitely want to make the function work.

  • I suggest looking into custom actions and custom action overrides (polymorphism)

    That aside, you can pass picking to a function by checking copy picked or pass a uid via a function parameter.

  • Do you have a link I should look at for (polymorphism)? I've never even heard of this and I'm very curious.

    Does anyone have a link showing this passing of a UID in action?

    I've been searching, but I keep finding old examples that link to with old doc links (that are dead) or old dropbox examples that have long since been deleted.

  • It's part of the custom action documentation.

    To pass a uid add a number function parameter. When calling the function you pass popUp.uid to that param. In the function you use the pick by uid condition with that parameter as value

  • For what you are describing above in the screenshots you can open the function and check 'copy picked', this will keep the picked family object inside the function for use with the actions.

  • lionz, "Copy Picked" works perfectly and was super easy to do - thank you so much!

    fedca, Thank you for your suggestions too. Even though I don't think I need them for this specific problem, I will still look into those for my future needs.

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