Wait 0

0 favourites
From the Asset Store
Add calm and a lounge vibe to your games with these 8 tracks
  • Hello,

    I was reading some tutorials and find the advanced tips and tricks from Whiteclaws

    After the read, I learned something ugly of my point of vision, as a non programmer and a common user of C2.

    ait 0 Seconds

    Wait 0 seconds is designed to postpone until the end of the current run of events (not even the next tick - the same tick, but after all other events).

    Explanation :

    Condition 1

    .. Event1

    .. Event2

    In this case , event 1 & event 2 will occur in the same tick

    Condition 1

    .. Event1

    .. Wait 0 seconds

    .. Event2

    Putting a 0 seconds will insure that Event2 will only occur after Event1 is finished

    Some examples ...

    On start of layout

    .. Create Object1

    .. Set Variable1 to 0

    Here , the two events occur in the same tick , meaning the object is created in the same moment as the variable is changed , The object isn't ready , so the variable is assigned before the object is created ... Doesn't work .

    If you place "Wait 0 seconds" between the two , C2 will spawn the instance , wait until it is ready , and then assign the variable

    This trick is very useful when you need to call a function then call another depending on the result of the last one ...

    scirra.com/tutorials/510/advanced-tips-and-tricks-that-construct2-offers

    I always believed C2 did the actions in sequence, without the necessity of waiting 0, also, I never saw a code using the wait 0 before, but if it's true, all my job will need to be redone, without the mention of my pupils =

    Ashley , do you can clarify if it's really necessary or just a "best practice" or C2 already do the actions in sequence?

    That's annoying create an object on the canvas, like an enemy, where you want setup his sine behavior to meet the route you wanted, and all this event run at same time, what could be a mess and/or miss the sine configuration to that specific object and/or shuffle it with another object spawned on the same event.

    Thank you for any advice!

  • never used "Wait 0 Seconds"

    and never had any issues with

    On start of layout

    .. Create Object1

    .. Set Variable1 to 0

    so not really sure what's this tutorial is reffering to.

  • EDIT: My post was completely wrong lol

  • Jase00: You can set instance variables on creation of the object without having to use "wait".

    It might be possible that accessing the value in another event but in the same tick as the creation might request to wait for at least one more tick (though I think Ash changed this and it actually isn't true anymore).

    But in your and Whiteclaws' examples that "wait 0" trick doesn't make any kind of sense to me. (Or maybe whiteclaws' example is badly formulated, since under a condition I'd expect Action1/Wait/Action2, perhaps this needs reformulating as the wait action would have to happen in a blank event)

  • Kyatric, excellent job on the university!

    I'm thinking about it and never occur something strange on creating and setting up an action where two or more objects are created and configured.

    But, it need a re-test with two objects of the same type (Example: two bullets) with different configuration from each other (example, an spaceship shooting two bullets, but one go 90? and the next one go 270?).

    So, the code could be (and was what I would make):

    Condition

    On touch screen

    Actions > Create bullet on layer "Game";

    Set bullet angle of motion to 90;

    Create bullet on layer "Game";

    Set bullet angle of motion to 270;

    Later I say what happened...

  • It's really ugly too as a programmer to wait a given time to ensure that an object is created before using it's properties or assigning values. If i had to do this, I would rely on events that are called after the creation of an object.

    However, like Kyatric said, it just works without using wait and I really dont see why it wouldn't.

  • Kyatric , could you suggest me an example , I'm fixing it now ...

    So the issue was fixed by Ashley ? My bad , sorry everyone ...

  • Everyone is getting confused over nothing. Objects are 100% created immediately and you can access every part of them immediately. There is rarely any need to use "Wait 0 seconds", and most projects will never use it.

    I think the quoted text was referring to the fact of a different quirk about creating objects. You can't pick a newly created object in another condition until the end of the next top-level event. Again that's not a problem for most projects, but in rare cases 'Wait 0 seconds' can be useful to help work around that.

    Edit: re-reading the quoted text, it's wrong. Assigning variables immediately after creating an object always works, and has always worked, there's never even been any bugs with that (IIRC).

  • Ashley , I'm sorry , I misurstood a text of yours , could you please correct it ?

  • Fixed ... Sorry everyone ...

  • No problem Whiteclaws, your logic maybe valid when using AS3 and flash, or C# or C++.

    I was worried because it had a huge impact on how I teach and use C2.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Actually I didn't know about this entire theory of Wait0 at the end of the first place. While I can't see much use for it. I might have one.

    Spriter

    There is an odd quirk in Spriter. let me explain it. Hopefully clearly :P

    * there is no way to set animation values in a Spriter object properties.

    * a spriter object upon creation will start animating

    * animations animate forward unless setspeed ratio is set to -value

    * cannot stop animation until it's initialized AFTER OnStartup is finished. It has something to do with the Spriter initialization association. Often this means until After the first tick of the object creation. You cant' stop the animation :(

    Now this creates an annoying occurance for me. My main menu for my Ouya game is done in Spriter. What often happens is that since no Spriter.StopAnation cannot occur until tick 1(ie after tick 0) the animation is already started. So when I set Spriter.AnimateToKeyFrame(0). The animation cycles through all the keyframes until it reaches the end and then hits 0. this really is frustrating.

    I'm wondering if Wait0 might help with this.

    ...........

    ........

    .....

    ...

    .

    well after two dozen tests and forced reloaded(ie play button). that seems to have done the trick... Thank you Wait0. You rock :) I will see if it holds out after many more dozens of tests :)

  • lol, this is a plugin missing a feature, why you don't ask the developer to make this action/condition for you?

  • jayderyu , what about me :D

  • You rock too White Claws. So far I haven't seen the problem occur at the start. I still get over framing elewhere, but not on the start :)

    Actually I've mentioned it to Lucid before and it is being looked into, but it also has something to do with just how C2 handles on Startup.

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