Giter VIP home page Giter VIP logo

spriterdotnet's Introduction

SpriterDotNet

A simple, fast and efficient Spriter implementation in pure C#

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.

Completed Plugins

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

How to use it

  1. Extend SpriterAnimator<TSprite, TSound> with generic parameters being the concrete types for the framework you're using and override ApplySpriteTransform and PlaySound methods
  2. Obtain a string with the SCML data
  3. Get a Spriter instance with SpriterParser.Parse
  4. Instantiate your SpriterAnimator class with the desired Entity
  5. Register concrete objects which correspond to FolderId/FileId
  6. Call Step in every frame
  7. Control the animation with properties

SpriterAnimator

This class contains the majority of Properties and Methods necessary to control the animation.

Properties
  • 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
Methods
  • 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

Points

  • Override SpriterAnimator.ApplyPointTransform

Collision Rectangles

  • Override SpriterAnimator.ApplyBoxTransform

Events

  • Subscribe to the SpriterAnimator.EventTriggered event

Variables

  • Query SpriterAnimator.Metadata

Tags

  • Query SpriterAnimator.Metadata

Character Maps

  • Set SpriterAnimator.CharacterMap to desired value or null

Animation Blending

  • 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.

Feedback

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.

spriterdotnet's People

Contributors

adamholdenyall avatar loodakrawa avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.