ModEnc is currently in Maintenance Mode: Changes could occur at any given moment, without advance warning.

Animation Looping: Difference between revisions

From ModEnc
Jump to navigation Jump to search
DeathFish (talk | contribs)
a lot
DeathFish (talk | contribs)
m Accurate boundary value
 
(One intermediate revision by the same user not shown)
Line 11: Line 11:
* {{f|LoopCount|link}} defines the total amount of iterations to play.
* {{f|LoopCount|link}} defines the total amount of iterations to play.
** Value {{tt|1}} is for a single iteration where the {{tt|LoopStart}} and {{tt|LoopEnd}} values are not used instead.
** Value {{tt|1}} is for a single iteration where the {{tt|LoopStart}} and {{tt|LoopEnd}} values are not used instead.
** Value {{tt|> 1}}, then the following two tags will be used:
** Value {{tt|≥ 2}}, then the following two tags will be used:
*** {{f|LoopStart|link}} defines a '''''0'''-based'' index of the first frame for loop iterations.
*** {{f|LoopStart|link}} defines a '''''0'''-based'' index of the first frame for loop iterations.
*** {{f|LoopEnd|link}} defines a '''''1'''-based'' index of the last frame when total number of iterations is more than one.
*** {{f|LoopEnd|link}} defines a '''''1'''-based'' index of the last frame when total number of iterations is more than one.
Line 23: Line 23:
Have loop (0-based):
Have loop (0-based):


  {{f|Start|link}} -> {{f|LoopEnd|link}}{{tt|-1}} -- [{{f|LoopCount|link}}-1 times] --><-> {{f|LoopStart|link}} -> {{tt|Start+End}}{{tt|-1}}
  {{f|Start|link}} -> {{f|LoopEnd|link}}{{tt|-1}} -- [{{f|LoopCount|link}}-1 times] --><-> {{f|LoopStart|link}} -> {{tt|Start+End}} {{tt|-1}}


*If {{tt|Start}} > {{tt|LoopEnd-1}}, animation will only play {{tt|1}} frame using the index specified by {{tt|Start}} and then directly enter the second Loop;
*If {{tt|Start}} {{tt|LoopEnd-1}}, animation will only play {{tt|1}} frame using the index specified by {{tt|Start}} and then directly enter the second Loop;
*If {{tt|LoopStart}} ≥ {{tt|LoopEnd - 1}}, then display 1 frame of {{tt|LoopStart}}, and then proceed to the next Loop.
*If {{tt|Start+End -1}} ≤ {{tt|LoopStart}}, animation will only play {{tt|1}} frame using the index specified by {{tt|LoopStart}} and then end.
*If {{tt|Start+End -1}} ≤ {{tt|LoopStart}}, animation will only play {{tt|1}} frame using the index specified by {{tt|LoopStart}} and then end.
From {{tt|2}} to {{tt|10}}, there are {{tt|9}} numbers instead of {{tt|10-2}}={{tt|8}}. And {{tt|10}}={{tt|2+9-1}}.
From {{tt|2}} to {{tt|10}}, there are {{tt|9}} numbers instead of {{tt|10-2}}={{tt|8}}. And {{tt|10}}={{tt|2+9-1}}.
Line 33: Line 34:
None loop (1-based):
None loop (1-based):


  {{f|Start|link}}{{tt|+1}} -> {{tt|Start+}}{{f|End|link}} (← {{tt|Start+1 + End - 1}})
  {{f|Start|link}}{{tt|+1}} -> {{tt|Start+}}{{f|End|link}} (← {{tt|Start+1 + End -1}})


Have loop (1-based):
Have loop (1-based):


  {{f|Start|link}}{{tt|+1}} -> {{f|LoopEnd|link}} -- [{{f|LoopCount|link}}-1 times] --><-> {{f|LoopStart|link}}{{tt|+1}} -> {{tt|Start+End}} (← {{tt|Start+1 + }}{{f|End|link}}{{tt| - 1}})
  {{f|Start|link}}{{tt|+1}} -> {{f|LoopEnd|link}} -- [{{f|LoopCount|link}}-1 times] --><-> {{f|LoopStart|link}}{{tt|+1}} -> {{tt|Start+End}} (← {{tt|Start+1 + }}{{f|End|link}} {{tt| -1}})


*If {{tt|Start+1}} > {{tt|LoopEnd}}, animation will only play {{tt|1}} frame using the index specified by {{tt|Start+1}} and then directly enter the second Loop;
*If {{tt|Start+1}} {{tt|LoopEnd}}, animation will only play {{tt|1}} frame using the index specified by {{tt|Start+1}} and then directly enter the second Loop;
*If {{tt|LoopStart + 1}} ≥ {{tt|LoopEnd}}, then display 1 frame of {{tt|LoopStart + 1}}, and then proceed to the next Loop.
*If {{tt|Start+End}} ≤ {{tt|LoopStart+1}}, animation will only play {{tt|1}} frame using the index specified by {{tt|LoopStart+1}} and then end.
*If {{tt|Start+End}} ≤ {{tt|LoopStart+1}}, animation will only play {{tt|1}} frame using the index specified by {{tt|LoopStart+1}} and then end.
From {{tt|2}} to {{tt|10}}, there are {{tt|9}} numbers instead of {{tt|10-2}}={{tt|8}}. And {{tt|10}}={{tt|2+9-1}}.
From {{tt|2}} to {{tt|10}}, there are {{tt|9}} numbers instead of {{tt|10-2}}={{tt|8}}. And {{tt|10}}={{tt|2+9-1}}.

Latest revision as of 21:57, 10 February 2025

Here is the animation looping control flag descriptions. The loop control allows to set start/end frames for the first iteration of the loop and start/end frames for all other iterations in the loop.

Animations

The following apply to any animation:

  • Start defines a 0-based index of the first frame to play on the first iteration.
    • Start is used for first iteration irrespective of the number of total iterations defined for this animation. Start defaults to 0 if not defined.
  • End defines the number of frames starting from the frame number specified by Start(0-based). So when Start=0, you can consider End as the frame index(1-based) of the ending.
    • it could be the shadow frames as well unless Shadow=yes is set in RA2/YR making it to end with the last normal frame.
  • LoopCount defines the total amount of iterations to play.
    • Value 1 is for a single iteration where the LoopStart and LoopEnd values are not used instead.
    • Value ≥ 2, then the following two tags will be used:
      • LoopStart defines a 0-based index of the first frame for loop iterations.
      • LoopEnd defines a 1-based index of the last frame when total number of iterations is more than one.
    • Value -1 is used for infinite loop.

Notes (0-based)

None loop :

Start -> Start+End -1

Have loop (0-based):

Start -> LoopEnd-1 -- [LoopCount-1 times] --><-> LoopStart -> Start+End -1
  • If StartLoopEnd-1, animation will only play 1 frame using the index specified by Start and then directly enter the second Loop;
  • If LoopStartLoopEnd - 1, then display 1 frame of LoopStart, and then proceed to the next Loop.
  • If Start+End -1LoopStart, animation will only play 1 frame using the index specified by LoopStart and then end.

From 2 to 10, there are 9 numbers instead of 10-2=8. And 10=2+9-1.

  • This is obvious, so you need to -1 at the end to get the frame index.

Notes (1-based)

None loop (1-based):

Start+1 -> Start+End (← Start+1 + End -1)

Have loop (1-based):

Start+1 -> LoopEnd -- [LoopCount-1 times] --><-> LoopStart+1 -> Start+End (← Start+1 + End  -1)
  • If Start+1LoopEnd, animation will only play 1 frame using the index specified by Start+1 and then directly enter the second Loop;
  • If LoopStart + 1LoopEnd, then display 1 frame of LoopStart + 1, and then proceed to the next Loop.
  • If Start+EndLoopStart+1, animation will only play 1 frame using the index specified by LoopStart+1 and then end.

From 2 to 10, there are 9 numbers instead of 10-2=8. And 10=2+9-1.

  • This is obvious, so you need to -1 at the end to get the frame index.

Bugs/Side-Effects/Unexpected Limitations

If an animation of a Loop is used by another animation via Next, then its Start will be calculated by multiplying by 2.

  • For example, the following code will make RING1 and PDFXLOC both stay for 2 frames at frame 11 (1-based) of the Shape before swapping.
  • However, if RING1 or PDFXLOC are created using AnimList, the first playback will start from frame 6 (1-based).
[AnyAnim]
Next=RING1

[RING1]
Start=5
LoopStart=10
LoopEnd=11
End=6
LoopCount=2
Next=PDFXLOC

[PDFXLOC]
Start=5
LoopStart=10
LoopEnd=11
End=6
LoopCount=2
Next=RING1

That is,

  • Start*2 -> LoopEnd-1 -- [LoopCount-1 times] --> LoopStart+0 -> Start+End-1 for 0-based index;
  • Start*2+1 -> LoopEnd -- [LoopCount-1 times] --> LoopStart+1 -> Start+End-0 for 1-based index.

Correspondingly, this causes you to be unable to stably play even-numbered (1-based) frames.

  • For example, you cannot stably use the 10th (1-based) frame for the above RING1 and PDFXLOC, because Start will insert an odd-numbered (1-based) frame.

Projectiles

Animated projectiles have their own set of flags which achieve the same effect as the loop flags above, albeit with somewhat less control.

  • AnimLow defines a 0-based index of the first frame.
  • AnimHigh defines a 0-based index of the last frame.

The animation will loop indefinitely until the projectile expires in one way or another.

See Also

Next

AnimRate