Function not keeping object scope?

0 favourites
  • 3 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I was using the function plugin from rex until upgrading to R111 from R108.2, after which I noticed a few bugs appearing. As an experiment I switched over to the official function plugin but noticed the same behaviour.

    The issue seems to be that if I select a sprite and then, in that context, perform an action on it, the code inside the function loses context. Previously this was working fine, but now breaks in both the plugin by rex and the official plugin.

    For example, in this code the score only registers as 50 (the first box in the layout), despite there being a second box I am clicking on with a score of 100.

    <img src="http://i.imgur.com/HNJ5P.png" border="0">

    Sample Capx

    What I'm curious about is, should I indeed have the scope of the calling event? Or is the function separate from the context of where it is called? Is this something that changed post R108.2?

    Cheers!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The list of all changes is available in the changelog of each version.

    In your case, in r110.2:

    ug fix: Function: in some cases the called function would still reference objects picked from the event calling the function. This was not intended; now function events start picking instances from scratch again.

    Pass the UID of the sprite as a parameter of your function and as a subevent or other condition of the "on" function definition, pick the sprite by UID.

  • Thanks Kyatric.

    I read the release notes but I think I misunderstood that to mean it was picking objects outside the scope of the calling function (seeing as how I thought the bug it fixed was how it was actually supposed to work). No worries, I'll pass the UID in and repick the object.

    Thanks mate.

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