Skip to content

Commit d3a8804

Browse files
Merge pull request #86 from AristurtleDev/develop
5.1.0 Release
2 parents 18cfbc5 + babeabd commit d3a8804

File tree

7 files changed

+70
-20
lines changed

7 files changed

+70
-20
lines changed

.github/release-notes.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,8 @@
4141
- Resolved issue where MonoGame.Aseprite.dll assembly reference was required for the MonoGame.Aseprite.Content.Pipeline.dll assembly in the mgcb-editor (Closes #76)
4242
- `TextureRegion.TryGetSlice` and `TextureRegion.TryGetSlice<T>` methods added (credit: @fdrobidoux)
4343

44+
## 5.1.0
45+
- `AsepriteCel` properties were made public (thanks @SephDB)
46+
- `AnimatedSprite` now supports setting frame both on initial play and during playback.
47+
4448

.nuget/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
A Cross Platform C# Library That Adds Support For Aseprite Files in MonoGame Projects.
44

55
[![build-and-test](https://github.com/AristurtleDev/monogame-aseprite/actions/workflows/buildandtest.yml/badge.svg)](https://github.com/AristurtleDev/monogame-aseprite/actions/workflows/buildandtest.yml)
6-
[![Nuget 5.0.1](https://img.shields.io/nuget/v/MonoGame.Aseprite?color=blue&style=flat-square)](https://www.nuget.org/packages/MonoGame.Aseprite/5.0.1)
6+
[![Nuget 5.1.0](https://img.shields.io/nuget/v/MonoGame.Aseprite?color=blue&style=flat-square)](https://www.nuget.org/packages/MonoGame.Aseprite/5.1.0)
77
[![License: MIT](https://img.shields.io/badge/📃%20license-MIT-blue?style=flat)](LICENSE)
88
[![Twitter](https://img.shields.io/badge/%20-Share%20On%20Twitter-555?style=flat&logo=twitter)](https://twitter.com/intent/tweet?text=MonoGame.Aseprite%20by%20%40aristurtledev%0A%0AA%20cross-platform%20C%23%20library%20that%20adds%20support%20for%20Aseprite%20files%20in%20MonoGame%20projects.%20https%3A%2F%2Fgithub.com%2FAristurtleDev%2Fmonogame-aseprite%0A%0A%23monogame%20%23aseprite%20%23dotnet%20%23csharp%20%23oss%0A)
99

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
A Cross Platform C# Library That Adds Support For Aseprite Files in MonoGame Projects.
55

66
[![build-and-test](https://github.com/AristurtleDev/monogame-aseprite/actions/workflows/buildandtest.yml/badge.svg)](https://github.com/AristurtleDev/monogame-aseprite/actions/workflows/buildandtest.yml)
7-
[![Nuget 5.0.1](https://img.shields.io/nuget/v/MonoGame.Aseprite?color=blue&style=flat-square)](https://www.nuget.org/packages/MonoGame.Aseprite/5.0.1)
7+
[![Nuget 5.1.0](https://img.shields.io/nuget/v/MonoGame.Aseprite?color=blue&style=flat-square)](https://www.nuget.org/packages/MonoGame.Aseprite/5.1.0)
88
[![License: MIT](https://img.shields.io/badge/📃%20license-MIT-blue?style=flat)](LICENSE)
99
[![Twitter](https://img.shields.io/badge/%20-Share%20On%20Twitter-555?style=flat&logo=twitter)](https://twitter.com/intent/tweet?text=MonoGame.Aseprite%20by%20%40aristurtledev%0A%0AA%20cross-platform%20C%23%20library%20that%20adds%20support%20for%20Aseprite%20files%20in%20MonoGame%20projects.%20https%3A%2F%2Fgithub.com%2FAristurtleDev%2Fmonogame-aseprite%0A%0A%23monogame%20%23aseprite%20%23dotnet%20%23csharp%20%23oss%0A)
1010

source/MonoGame.Aseprite.Content.Pipeline/MonoGame.Aseprite.Content.Pipeline.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<ImplicitUsings>enable</ImplicitUsings>
55
<Nullable>enable</Nullable>
66
<GenerateDocumentationFile>False</GenerateDocumentationFile>
7-
<Version>5.0.1</Version>
7+
<Version>5.1.0</Version>
88
</PropertyGroup>
99

1010
<PropertyGroup>
@@ -21,9 +21,9 @@
2121
<!-- dotnet pack Nuget Config stuff -->
2222
<PropertyGroup>
2323
<PackageId>MonoGame.Aseprite.Content.Pipeline</PackageId>
24-
<Version>5.0.1</Version>
25-
<AssemblyVersion>5.0.1</AssemblyVersion>
26-
<FileVersion>5.0.1</FileVersion>
24+
<Version>5.1.0</Version>
25+
<AssemblyVersion>5.1.0</AssemblyVersion>
26+
<FileVersion>5.1.0</FileVersion>
2727
<Authors>Christopher Whitley</Authors>
2828
<Company>Aristurtle</Company>
2929
<PackageLicenseExpression>MIT</PackageLicenseExpression>
@@ -38,10 +38,10 @@
3838
MonoGame;Aseprite;import;processes;read;write;sprite;animation;tileset;tilemap;spritesheet;pipeline;mgcb
3939
</PackageTags>
4040
<PackageReleaseNotes>
41-
Version 5.0.1
41+
Version 5.1.0
4242
The following changes were implemented:
43-
- Resolved issue where MonoGame.Aseprite.dll assembly reference was required for the MonoGame.Aseprite.Content.Pipeline.dll assembly in the mgcb-editor (Closes #76)
44-
- `TextureRegion.TryGetSlice` and `TextureRegion.TryGetSlice&lt;T&gt;` methods added (credit: @fdrobidoux)
43+
- `AsepriteCel` properties were made public (thanks @SephDB)
44+
- `AnimatedSprite` now supports setting frame both on initial play and during playback.
4545
</PackageReleaseNotes>
4646
<Description>
4747
MonoGame.Aseprite.Content.Pipeline is a cross-platform C# library that adds an extension to the MonoGame

source/MonoGame.Aseprite.Shared/AsepriteTypes/AsepriteCel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ public abstract class AsepriteCel
4040
/// Gets the x- and y-coordinate location of this <see cref="AsepriteCel"/> relative to the bounds of the
4141
/// <see cref="AsepriteFrame"/> it is in.
4242
/// </summary>
43-
internal Point Position { get; }
43+
public Point Position { get; }
4444

4545
/// <summary>
4646
/// Gets the opacity level of this <see cref="AsepriteCel"/>.
4747
/// </summary>
48-
internal int Opacity { get; }
48+
public int Opacity { get; }
4949

5050
/// <summary>
5151
/// Gets the custom <see cref="AsepriteUserData"/> that was set for this <see cref="AsepriteCel"/> in aseprite.
5252
/// </summary>
53-
internal AsepriteUserData UserData { get; } = new();
53+
public AsepriteUserData UserData { get; } = new();
5454

5555
internal AsepriteCel(AsepriteLayer layer, Point position, int opacity) =>
5656
(Layer, Position, Opacity) = (layer, position, opacity);

source/MonoGame.Aseprite/MonoGame.Aseprite.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<ImplicitUsings>enable</ImplicitUsings>
55
<Nullable>enable</Nullable>
66
<GenerateDocumentationFile>False</GenerateDocumentationFile>
7-
<Version>5.0.1</Version>
7+
<Version>5.1.0</Version>
88
</PropertyGroup>
99

1010
<PropertyGroup>
@@ -29,10 +29,10 @@
2929
</PackageTags>
3030
<PackageReadmeFile>README.md</PackageReadmeFile>
3131
<PackageReleaseNotes>
32-
Version 5.0.1
32+
Version 5.1.0
3333
The following changes were implemented:
34-
- Resolved issue where MonoGame.Aseprite.dll assembly reference was required for the MonoGame.Aseprite.Content.Pipeline.dll assembly in the mgcb-editor (Closes #76)
35-
- `TextureRegion.TryGetSlice` and `TextureRegion.TryGetSlice&lt;T&gt;` methods added (credit: @fdrobidoux)
34+
- `AsepriteCel` properties were made public (thanks @SephDB)
35+
- `AnimatedSprite` now supports setting frame both on initial play and during playback.
3636
</PackageReleaseNotes>
3737
<Description>
3838
MonoGame.Aseprite is a cross-platofrm C# library that adds support to MonoGame projects for

source/MonoGame.Aseprite/Sprites/AnimatedSprite.cs

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ public double Speed
9797
}
9898
}
9999

100+
/// <summary>
101+
/// Gets the total number of frames in this <see cref="AnimatedSprite"/>
102+
/// </summary>
103+
public int FrameCount => _animationTag.FrameCount;
104+
100105
/// <summary>
101106
/// Gets the source <see cref="AnimationFrame"/> of the current frame of animation for this
102107
/// <see cref="AnimatedSprite"/>.
@@ -202,6 +207,29 @@ public void Update(GameTime gameTime)
202207
}
203208
}
204209

210+
/// <summary>
211+
/// Sets the current frame of animation for this <see cref="AnimatedSprite"/>.
212+
/// </summary>
213+
/// <param name="frameIndex">
214+
/// The index of the frame to set. Value must be greater than zero and less than the total count of frames. You
215+
/// can use <see cref="AnimatedSprite.FrameCount"/> to determine the total number of frames.
216+
/// </param>
217+
/// <exception cref="ArgumentOutOfRangeException">
218+
/// Thrown if the <paramref name="frameIndex"/> value provided is less than zero or is greater than or equal to
219+
/// the total number of frames in this <see cref="AnimatedSprite"/>.
220+
/// </exception>
221+
public void SetFrame(int frameIndex)
222+
{
223+
if(frameIndex < 0 || frameIndex >= FrameCount)
224+
{
225+
throw new ArgumentOutOfRangeException(nameof(frameIndex), $"{nameof(frameIndex)} must be greater than zero and less than the total number of frames in this AnimatedSprite");
226+
}
227+
228+
_currentIndex = frameIndex;
229+
TextureRegion = CurrentFrame.TextureRegion;
230+
CurrentFrameTimeRemaining = CurrentFrame.Duration;
231+
}
232+
205233
private void AdvanceFrame()
206234
{
207235
OnFrameEnd?.Invoke(this);
@@ -267,13 +295,30 @@ private void ReduceLoopsRemaining()
267295
/// ping-pong will count as a loop.
268296
/// </para>
269297
/// </param>
298+
/// <param name="startingFrame">
299+
/// <para>
300+
/// When this value is provided, specifies the frame to start the animation at
301+
/// </para>
302+
/// <para>
303+
/// When <see langword="null"/> is provided, play will start at frame 0 of the animation.
304+
/// </para>
305+
/// </param>
270306
/// <returns>
271307
/// <see langword="true"/> if animation play was successfully started for this <see cref="AnimatedSprite"/>;
272308
/// otherwise, <see langword="false"/>. This method returns <see langword="false"/> if the animation is already
273309
/// playing (when <see cref="AnimatedSprite.IsAnimating"/> equals <see langword="true"/>).
274310
/// </returns>
275-
public bool Play(int? loopCount = default)
311+
/// <exception cref="ArgumentOutOfRangeException">
312+
/// Thrown if the <paramref name="startingFrame"/> value provided is less than zero or is greater than or equal to
313+
/// the total number of frames in this <see cref="AnimatedSprite"/>.
314+
/// </exception>
315+
public bool Play(int? loopCount = default, int? startingFrame = 0)
276316
{
317+
if(startingFrame < 0 || startingFrame >= FrameCount)
318+
{
319+
throw new ArgumentOutOfRangeException(nameof(startingFrame), $"{nameof(startingFrame)} must be greater than zero and less than the total number of frames in this AnimatedSprite");
320+
}
321+
277322
// Cannot play something that's already playing
278323
if (IsAnimating)
279324
{
@@ -291,14 +336,15 @@ public bool Play(int? loopCount = default)
291336
IsAnimating = true;
292337
IsPaused = false;
293338

294-
_currentIndex = 0;
339+
_currentIndex = startingFrame ?? 0;
295340

296341
if (IsReversed)
297342
{
298343
_currentIndex = _animationTag.Frames.Length - 1;
299344
}
300345

301346
TextureRegion = CurrentFrame.TextureRegion;
347+
CurrentFrameTimeRemaining = CurrentFrame.Duration;
302348
_hasBegun = false;
303349

304350
return true;
@@ -398,8 +444,8 @@ public bool Stop()
398444

399445
/// <summary>
400446
/// Resets this <see cref="AnimatedSprite"/> back to its initial state as defined by the
401-
/// <see cref="AnimationTag"/> used to create it. You will need to call <see cref="AnimatedSprite.Play(int?)"/>
402-
/// after resetting to start the playback of the animation.s
447+
/// <see cref="AnimationTag"/> used to create it. You will need to call <see cref="AnimatedSprite.Play(int?, int?)"/>
448+
/// after resetting to start the playback of the animation.
403449
/// </summary>
404450
/// <remarks>
405451
/// <para>

0 commit comments

Comments
 (0)