A simple, fast and efficient Spriter implementation in pure C#
The goal of SpriterDotNet is to be as fast as possible while keeping the code clean and readable. Being a pure C# implementation, SpriterDotNet doesn't depend on any external libraries / frameworks. It focuses on simple and efficient calculations of all transforms at a given point in time. This allows using it with any framework just by mapping calculated transforms to concrete objects.
- Unity
- Monogame
- Basic animations
- Bone animations
- All curve types (Instant, Linear, Quadratic, Cubic, Quartic, Quintic, Bezier)
- Points
- Collision Rectangles
- SubEntities
- Events
- Sounds
- Variables
- Tags
- Character maps
- Animation Blending
- Extend SpriterAnimator<TSprite, TSound> with generic parameters being the concrete types for the framework you're using and override ApplySpriteTransform and PlaySound methods
- Obtain a string with the SCML data
- Get a Spriter instance with SpriterParser.Parse
- Instantiate your SpriterAnimator class with the desired Entity
- Register concrete objects which correspond to FolderId/FileId
- Call Step in every frame
- Control the animation with properties
This class contains the majority of Properties and Methods necessary to control the animation.
- Speed - Playback speed. Negative speeds reverse the animation
- Time - The current time in animation in milliseconds
- Progress - The progress of animation. Ranges from 0.0f to 1.0f
- Play(string name) - Plays the given animation
- Transition(string name, float totalTransitionTime) - Transitions to given animation doing a progressive blend in the given time
- Blend - Blends two animations with the given weight factor
- Override SpriterAnimator.ApplyPointTransform
- Override SpriterAnimator.ApplyBoxTransform
- Subscribe to the SpriterAnimator.EventTriggered event
- Query SpriterAnimator.Metadata
- Query SpriterAnimator.Metadata
- Set SpriterAnimator.CharacterMap to desired value or null
- Call SpriterAnimator.Transition or SpriterAnimator.Blend
Animation blending is possible only between animations with identical hierarchies. Blending incompatible animations will cause strange behaviour. SpriterDotNet only performs a simple check to determine compatibility in order to avoid crashing but that might not be enough in some cases.
A IAnimationDataProvider instance is used by the SpriterAnimator to get all the required data. If you need custom behaviour, you can either implement this interface or extend one of the existing providers and set it as SpriterAnimator.DataProvider.
For questions, feedback, complaints, etc, use the related topic on Spriter Forum
Also, feel free to drop a note if you use SpriterDotNet in your game/project and I'll be happy to add a showcase section with links to your game/project.