Functions behaving weird when using wait action

0 favourites
  • 3 posts
From the Asset Store
Add calm and a lounge vibe to your games with these 8 tracks
  • I created 3 functions:

    1_ control the visibility of an input layer

    2_ generates objects according to the value of the variable X

    3_ increments the level and defines a new one for the X variable

    In the first function, I use a "wait x seconds" action to control the display time of the layer and then call the function that generates objects. After the user interacts with the game, I call the function that increments the level, and in the end, it itself calls the first function again.

    My problem is that the variable seems like it never gets updated, but as soon as I disable the "wait" action in the first function, everything works perfectly. Any idea how to resolve this?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You have to be careful when using waits in functions because they continue to run and depending on how you structured it you could be running events at the bottom first. Adding the wait to the top doesn't mean it will wait to run the rest of the function if there are multiple conditions.

    As described you could use the Timer behaviour for the display thing. Start a timer and then make use of 'on timer complete', then no need to use a function or waits.

  • Ok. Thanks for the explanation. I will use Timer instead of wait action.

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