loodakrawa

SpriterDotNet - An implementation for all C# frameworks

177 posts in this topic

SpriterDotNet
A simple, fast and efficient Spriter implementation in pure C#. Feature complete.
 
About
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.
 
Supported Features
  • 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
 
Plugins / Examples
 
Source Code
 
JohnnyType likes this

Share this post


Link to post
Share on other sites
Hi guys,

 

I attempted a rather different approach and made a pure C# implementation of Spriter that can be used with basically any .Net based framework. I'm going to release it as an open source project in the next couple of weeks.

Also, I'm going to provide examples in several frameworks (Unity, MonoGame and SDL.Net). And to provide that, I need actual .scml files.

 

Are these the most up-to-date official .scml files? If not, where can I find the most recent ones?

Also, how are they licensed? Or in other words, can I distribute them as examples in my library?

Share this post


Link to post
Share on other sites

Awesome, thanks!

I'll keep you guys posted about the status. The actual implementation is stable - I'll publish it as soon as I have a decent example.

Share this post


Link to post
Share on other sites

I'm glad you guys are interested! :)

The implementation is working fine with the exception of advanced curve types (Quadratic and Cubic) - I contacted lucid about it and currently waiting for clarification.

 

In the meantime I'm polishing the MonoGame example.

 

I'll give it a day or two, and if I don't get an answer / don't manage to solve the curves issue, I'll publish it with just the linear curves and update it later.

Share this post


Link to post
Share on other sites

Good news! While waiting for Lucid to answer my questions I found enlightenment and I managed to make Quadratic, Cubic, Quartic and Quintic curves to work.

 

Also, I polished the MonoGame example and added another SCML to test various scenarios.

 

I pushed the code on GitHub and hopefully it's going to work on other people's machines.

 

I'd like to hear any feedback/suggestions you guys have.

 

Cheers

Share this post


Link to post
Share on other sites

I will give this a go tonight.  Are there any known limitations on this implementation ?

 

Not really. The only thing is that this is just a C# implementation and it needs a little bit of work to use with any framework. It's not strictly plug n' play. But from my point of view, that's a plus because it keeps a clean separation of concerns.

 

Let me know how your testing goes.

 

In other news, I added the Unity example as well. Had a bit of trouble with Unity and source control but I think I got it under control now.

Share this post


Link to post
Share on other sites

Ok I have it working and everything was going fine until I tried the wonky skeleton asset from Spriter.  Its walk loop animation works up to the point of the loop (end of anim) the skeleton appears to head butt the floor, then it resets to the correct places and continues fine.  Any ideas ?  Do you need a video or asset to test with ?

 

Cheers and great work !!

Share this post


Link to post
Share on other sites

Ok I have it working and everything was going fine until I tried the wonky skeleton asset from Spriter.  Its walk loop animation works up to the point of the loop (end of anim) the skeleton appears to head butt the floor, then it resets to the correct places and continues fine.  Any ideas ?  Do you need a video or asset to test with ?

 

Cheers and great work !!

 

I managed to get the WonkySkeleton walk animation working. However, I noticed that the Crumble animation also behaves in a strange way so I'm investigating that at the moment. Did you encounter any other animations that behave in a strange way? I'm trying to find more examples since the skeleton is rather complex and that makes it harder to pinpoint the actual cause. I'll update the lib when I fix the second problem as well.

Share this post


Link to post
Share on other sites

The Crumble animation is tricky because it puts use to a little known or understood feature in Spriter that allows for each key-frame to have a completely different hierarchy as needed... at any key-frame in an animation, Spriter lets you completely change which bones or sprites are children of which other bones, or even completely add or delete sprites or bones on the fly.

 

cheers.

Share this post


Link to post
Share on other sites

Oh, that explains a lot. I was crunching through a lot of data and going through raw XML never bothering to actually look in Spriter :)
As always, thanks Mike for the quick support.

 

I updated the GitHub source and now the Walking animation should work fine. Also, I added the issue of animations with changing hierarchy as an enhancement for the future (when this feature gets documented)

Share this post


Link to post
Share on other sites

Known Issues

I can probably help you get this working without having to wait for the documentation. Basically, if you're already working with the mainline keys and using the bone_refs and object_refs to get the keyframes you need, it should be mostly automatic. 

for instance. If you have something like:

<bone_ref id="3" parent="2" timeline="16" key="1"/>

you would go to timelines[16], and the key[1]. You always tween with the very next key ( [2] in this case). Always do the tweens with the next key as if there is no changing hierarchy, using the hierarchy of that current key (in this example, the parent="2", tween normally without checking if there is a hierarchy change on the next key). The refs will automatically point you to the correct keys, and you don't actually have to do anything else to support it aside from the usual reading of the hierarchy from the mainline key.

If you're not using the refs and are instead looping through the each object's timeline to get the current key, the only additional thing you have to do is that if the time manages to land at the exact time of a timeline's keyframe (currentTime=timelineKey.time), you still need to check if the very next key also has that exact time. If so, use that one instead. All the rest should work automatically as above.

Please let me know if this helps, and feel free to pm or email me (lucid@brashmonkey.com) if you need additional info.

Share this post


Link to post
Share on other sites

Hello,  I have tried the latest version and the walk is now working :)  great stuff !

 

I have the walk + idle working 100%.  The crumble + attack anims work but dont loop.  The other anims dont start/loop.

 

Let me know if you need any more info/video.

 

Thanks,

Dave.

Share this post


Link to post
Share on other sites

Hello,  I have tried the latest version and the walk is now working :)  great stuff !

 

I have the walk + idle working 100%.  The crumble + attack anims work but dont loop.  The other anims dont start/loop.

 

Let me know if you need any more info/video.

 

Thanks,

Dave.

 

I changed the default behaviour from forcing the loop to respecting the data from the scml. Based on this, Walk and Idle are looping and Get_hit_0, Get_hit_1, Attack, Crumble, Regenerate and Gonna_Regenerate don't. Crumbled also technically loops but it only has one keyframe so it looks static.

 

I added the X key to reset the animation for testing animations that don't loop. IMO, it's easier to see what's going on if you loop these animations on demand.

 

If you want all the animations to loop you can either override the AnimationFinished method (or Step if you need more constrol) in MonogameSpriterAnimator or your derived class.

 

Let me know if you have any other issues.

 

Cheers

Share this post


Link to post
Share on other sites

That makes sense.  All seems to work now inside my framework :cool:   I had one issue with the bat animations where the 'a' attribute can be "nan".

 

I added this to SpriterSpatialInfo to fix it for me -

 

[XmlAttribute("a")]
        public string a 
        {            
            set
            {
                if (!(value == "nan" || value == ""))                    
                    Alpha = float.Parse(value);
            }
        }
 
Thanks for all your work on this.  Its brilliant !
 
Cheers,
Dave.

Share this post


Link to post
Share on other sites

 

That makes sense.  All seems to work now inside my framework :cool:   I had one issue with the bat animations where the 'a' attribute can be "nan".

 

I added this to SpriterSpatialInfo to fix it for me -

 

[XmlAttribute("a")]
        public string a 
        {            
            set
            {
                if (!(value == "nan" || value == ""))                    
                    Alpha = float.Parse(value);
            }
        }
 
Thanks for all your work on this.  Its brilliant !
 
Cheers,
Dave.

 

 

Good catch!

 

Everything alpha related should be fixed now.

 

Out of interest - which framework do you use?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.