0 Favourites

New functions: Pass object as parameter

  • Hey there

    I think it�s (still, maybe in the future?) not possible to do this, but I�m asking it cuz you know more than me.

    The new functions are really cool and useful, but, for example, if I want to create and object inside a function, I can pass parameters for example, the x or y positions of the newly created object, but, is there any way of passing the object to create in the function too?

    As always, thanks for all your help!

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • I am currently using strings to check for which object to create in my function. The thing is in any Object-Oriented Languange, it is impossible to pass an object into a function without first creating the object(it will throw exceptions). You can use an enumerator or string and based on that to create the object in the function.

  • Ummm, ok, thanks man, it�s logical.

    Anyway, I knew I couldn�t pass the object itself, but I was thinking if maybe the option of passing a string with the object name would be possible.

    So, the solution is to pass a parameter (a number, a string) and make and if statement inside the functions, isn�t it? (sorry for this, my english is... well, there is no word to define it xD).

  • msv0001 - that's not quite right, in Construct 2 you can pass instances to functions by passing their UID as a parameter.

    @sirLobito - you have to pass a string and check for each possible value of the string in subevents right now - unfortunately you can't create an object by name (due to the fact the obfuscator on export will change object names).

  • due to the fact the obfuscator on export will change object names

    That?s totally clarifier, ok, strings as parameters, no prob, thanks :).

  • Ashley - But if the instance is not creayed in the first place, there would be no UID. sirLobito was asking for a custom constructor as a function. Correct me if I have misinterpreted the question.

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