Skip to content
This repository was archived by the owner on Apr 19, 2024. It is now read-only.

Commit ed92074

Browse files
committed
looping
1 parent b3fee0d commit ed92074

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

ProjectStarlight.Interchange.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@
5454
<Compile Include="Utilities\FrameUtilities.cs" />
5555
<Compile Include="Utilities\GIFBuilder.cs" />
5656
</ItemGroup>
57-
<ItemGroup>
58-
<Folder Include="Utilities\DataStructures\" />
59-
</ItemGroup>
57+
<ItemGroup />
6058
<ItemGroup>
6159
<None Include="packages.config" />
6260
</ItemGroup>

TextureGIF.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ public class TextureGIF
1414

1515
public bool IsPaused { get; private set; }
1616

17-
public bool HasEnded => FrameIndex >= Frames.Length && FrameTick >= TicksPerFrame;
17+
public bool HasEnded => FrameIndex >= Frames.Length && FrameTick >= TicksPerFrame && !ShouldLoop;
18+
19+
public bool ShouldLoop { get; set; }
1820

1921
public int TicksPerFrame { get; set; }
2022

@@ -60,6 +62,7 @@ public void Stop()
6062
// This essentially sets HasEnded to true.
6163
FrameTick = Frames.Length - 1;
6264
FrameTick = TicksPerFrame;
65+
ShouldLoop = false;
6366
}
6467

6568
/// <summary>
@@ -139,6 +142,8 @@ public void ForwardTicks(int tickAmount)
139142

140143
if (FrameIndex < Frames.Length - 1)
141144
FrameIndex++;
145+
else if (ShouldLoop)
146+
FrameIndex = 0;
142147
}
143148
}
144149
}

0 commit comments

Comments
 (0)