Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For a couple games I made to solve this problem I created two animation classes</p> <p>asyncAnimation - For fire and forget type animations</p> <p>syncAnimation - If I wanted to wait for the animation to resolve before returning control</p> <p>As games usually have a main loop it looked something like this C# style psuedo code</p> <pre class="lang-csharp prettyprint-override"><code>while(isRunning) { renderStaticItems(); renderAsyncAnimations(); if (list_SyncAnimations.Count() &gt; 0) { syncAnimation = list_SyncAnimations.First(); syncAnimation.render(); if (syncAnimation.hasFinished()) { list_SyncAnimations.removeAt(0); // May want some logic here saying if // the sync animation was 'player dying' update some variable // so that we know the animation has ended and the // game can prompt for the 'try again' screen } } else { renderInput(); handleOtherLogic(); // Like is player dead, add sync animation if required. } } </code></pre> <p>So what the code does is maintain a list of sync animations that need to be resolved before continuing with the game - If you need to wait for several animations just stack them up.</p> <p>Also, it might be a good idea to look into the command pattern or provide a callback for when the sync animation has finished to handle your logic - its really up how you want to do it.</p> <p>As for your "Spawn at sec 1.13" perhaps the SyncAnimation class should have an overridable .OnUpdate() method, which can do some custom logic (or call a script)</p> <p>It depends what your requirements may be.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload