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

Animation Looping

From ModEnc
Revision as of 14:45, 10 February 2025 by DeathFish (talk | contribs) (→‎Notes)
Jump to navigation Jump to search

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 to play for the first iteration . End is only used if the total number of iteration is 1, which happens when LoopCount is not defined or LoopCount=1.
    • If the total number of iterations is more than 1, then End value is disregarded and instead LoopEnd is used. and the first iteration will end anyway with the LoopEnd frame of the SHP (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).

  • 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.
  • LoopCount defines the total amount of iterations to play. Value 1 is for a single iteration where the Start and End values are used instead of LoopStart and LoopEnd. Value -1 is used for infinite loop.
  • End flag when total number of iteration larger than 1 ( LoopCount more than 1):
    • If End > LoopEnd, it will control the frame that needs to be played after the last Loop.
      • In this case, it represents the frame index starting from 1.
    • If End <= LoopEnd, then LoopEnd will end directly.

Notes

No loop (1-based):

Start+1 -> Start+End

  • Start defines a 0-based index
  • End defines the number of frames to play

Have loop:

Start -> LoopEnd -- [LoopCount-1 times] --> LoopStart -> LoopEnd -> End(if End <= LoopEnd, end directly)

  • End defines a 1-based index

In order to facilitate understanding that Start does not necessarily have to be less than LoopStart,

the loop process is represented here by LoopEnd -> LoopStart for LoopCount-1 times, plus the final LoopStart -> LoopEnd.

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 + 0, (End-1) * 2 + 0 for 0-based index;
  • Start * 2 + 1, (End-1) * 2 + 1 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