Why i need to put "Wait 0 seconds" between functions ?

1 favourites
  • 4 posts
From the Asset Store
Like tourists, Travel around the world as fast as you can!
  • "generate_tile" functions only create 16 small sprites, but the next functions "add_number" are not working, since its pick one of 16 sprites that created on previous functions.

    I can fix it by put "Wait 0 seconds" in the middle, its not clean way, i'm just worried its will causing another problem if the events are getting complicated.

    I remember a few year ago when i can't figure out what wrong with my events, then i can fix it by put "wait" on it.

    Is possible to make functions work synchronous or blocking ?

  • the reason you need the wait 0 is that object creation does not complete until the next top level event.

    so, in your case event one must completely finish before the objects created in the function can be picked by "normal" means. (you can pick by UID or Last Created before then)

    adding the wait 0 defers actions until the end of current tick - which means the event that created the objects has completed.

    you could add another event to call the second function, but to do that you would have to set up some kind of trigger for that, which would only add more trouble than the wait 0.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • the reason you need the wait 0 is that object creation does not complete until the next top level event.

    so, in your case event one must completely finish before the objects created in the function can be picked by "normal" means. (you can pick by UID or Last Created before then)

    adding the wait 0 defers actions until the end of current tick - which means the event that created the objects has completed.

    you could add another event to call the second function, but to do that you would have to set up some kind of trigger for that, which would only add more trouble than the wait 0.

    Thank you!

    Previously i think functions are working like regular js functions.

  • Wouldn't it be easier to have a single function that does the same as the 2?

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