FlatRedBall.AnimationChain.MonoGame 0.5.0-preview.1

This is a prerelease version of FlatRedBall.AnimationChain.MonoGame.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package FlatRedBall.AnimationChain.MonoGame --version 0.5.0-preview.1
                    
NuGet\Install-Package FlatRedBall.AnimationChain.MonoGame -Version 0.5.0-preview.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FlatRedBall.AnimationChain.MonoGame" Version="0.5.0-preview.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FlatRedBall.AnimationChain.MonoGame" Version="0.5.0-preview.1" />
                    
Directory.Packages.props
<PackageReference Include="FlatRedBall.AnimationChain.MonoGame" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FlatRedBall.AnimationChain.MonoGame --version 0.5.0-preview.1
                    
#r "nuget: FlatRedBall.AnimationChain.MonoGame, 0.5.0-preview.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FlatRedBall.AnimationChain.MonoGame@0.5.0-preview.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FlatRedBall.AnimationChain.MonoGame&version=0.5.0-preview.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=FlatRedBall.AnimationChain.MonoGame&version=0.5.0-preview.1&prerelease
                    
Install as a Cake Tool

FlatRedBall.AnimationChain

A standalone library for loading and playing .achx (XML) or .achj (JSON) sprite animation files created by the FlatRedBall Animation EditorAchxLoader picks the dialect from the file extension automatically. No FlatRedBall2 engine dependency required — drop it into any MonoGame or KNI project.

Choose a variant

Target platform Package
MonoGame DesktopGL FlatRedBall.AnimationChain.MonoGame
KNI / Blazor WASM FlatRedBall.AnimationChain.KNI
dotnet add package FlatRedBall.AnimationChain.MonoGame
# or
dotnet add package FlatRedBall.AnimationChain.KNI

Quick start

// LoadContent
_loader = new AchxLoader(GraphicsDevice);
_animations = _loader.Load("Content/player.achx");
_player = new AnimationPlayer<AnimationFrame>(_animations);
_player.Play("Run");

// Update
_player.Update(gameTime.ElapsedGameTime);

// Draw
spriteBatch.DrawAnimation(_player, position, Color.White);

// UnloadContent / Dispose
_loader.Dispose();

Copy the .achx and its PNGs next to each other (CopyToOutputDirectory). AchxLoader loads them with Texture2D.FromStream, not the MGCB pipeline.

Drawing

DrawAnimation uses MonoGame SpriteBatch conventions:

  • position is the top-left of the current frame's source rectangle (before per-frame offset), in screen pixels. Y increases downward.
  • scale multiplies the source rectangle. A 16×32 frame at scale: 3 is 48×96 on screen.
  • AnimationFrame.RelativeX / RelativeY are unscaled source pixels from the .achx. DrawAnimation applies them as offset * scale. Positive RelativeY moves the sprite down.
  • If the .achx was authored in a Y-up world, negate RelativeY or flip Y in your camera transform.

To stand a character on a ground point (x, y) (feet on y):

var frame = player.CurrentFrame;
int srcW = frame?.SourceRectangle?.Width ?? 0;
int srcH = frame?.SourceRectangle?.Height ?? 0;
float width = srcW * scale;
float height = srcH * scale;
spriteBatch.DrawAnimation(
    player,
    new Vector2(x - width / 2f, y - height),
    Color.White,
    scale: scale);

Empty pixels at the bottom of a cell still count in SourceRectangle.Height. If idle-up/down hover while left/right look planted, set RelativeY on those frames in the Animation Editor (or crop the source rect) so the shoes sit on the last row of the cell.

Use SamplerState.PointClamp for pixel art.

Playback notes

  • Play(name) is a no-op if that chain is already playing, so it is safe every frame. Unknown names are ignored and the current animation continues.
  • One AchxLoader owns and caches textures. Many AnimationPlayers can share one AnimationChainList.
  • DrawAnimation applies authored multiply color, alpha, and ColorOperation.Add (Add ends and restarts the SpriteBatch — see the method remarks). Per-frame shapes are data only. FlipDiagonal is authored and not applied (SpriteEffects has no diagonal option).
  • This package is not the FlatRedBall2 engine player. Sprite.PlayAnimation uses a different origin and Y axis — do not mix the two type systems.

Web / Blazor WASM (KNI)

The filesystem is unavailable in browser environments. Pre-fetch bytes and pass streams instead:

var achxBytes = await httpClient.GetByteArrayAsync("Content/player.achx");
var texBytes  = await httpClient.GetByteArrayAsync("Content/player.png");
_animations = _loader.Load(
    new MemoryStream(achxBytes),
    texPath => new MemoryStream(texBytes));

Key types

  • AchxLoader — loads .achx files from disk or a stream; caches textures by path; IDisposable.
  • AnimationPlayer<AnimationFrame> — drives playback. Call Play(name), Update(elapsed), read CurrentFrame.
  • SpriteBatchExtensionsspriteBatch.DrawAnimation(player, position, color) extension method.

License

MIT — see LICENSE.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.1-preview.1 48 8/19/2026
0.5.0-preview.1 47 8/19/2026
0.4.0-preview.1 52 8/19/2026
0.3.1-preview.1 80 5/30/2026