Code Monkey home page Code Monkey logo

monogame-sprites's Introduction

MonoGame-Sprites

Simple Sprites & bone-like Transformations for MonoGame projects.

What is it

This mini-lib implements basic sprite class with transformations, that also support hierarchy and bone-like transformation inheritance.

In simple words, this provide the very basics needed to create bone-based 2d animations.

Live example

To see a live example, open and execute the solution in this repo.

Using MonoGame-Sprites

Install

To install the lib you can use NuGet:

Install-Package MonoGame.Sprites

Or you can manually copy the source files from MonoSprites/Source/ into your project.

Main objects

This lib contains 4 main classes you should know:

Renderable

Provide the basic API and functionality of any renderable entity. If you want to create your own custom sprites, inherit from it.

Container

An entity that doesn't have any graphic representation of its own, but hold transformations to inherit to its children. Containers are good method to group together multiple sprites. For example, you can use it to scale or move a group of renderables evenly.

Sprite

A simple renderable image with transformation and optional children.

Transformations

A set of transformation properties, such as position, scale, rotation, zindex, color, etc..

Transformations class also implements the functionality to inherit transformations from parent to child instances. Normally you don't need to use this class directly, as it is used internally.

How to use

To create a new sprite:

MonoSprites.Sprite sprite = new MonoSprites.Sprite(Content.Load<Texture2D>("sprite_texture"));

And to draw it:

spriteBatch.Begin(SpriteSortMode.FrontToBack);
sprite.Draw(spriteBatch);
spriteBatch.End();

To create a container and use it:

MonoSprites.Container container = new MonoSprites.Container();
MonoSprites.Sprite sprite = new MonoSprites.Sprite(Content.Load<Texture2D>("sprite_texture"), parent: container);
// or: container.AddChild(Sprite);

Now every transformation you apply on the container will be inherited to the child sprite.

For more info you can check out the code (with focus on the Renderable and Sprite public API), or read the automatically generated doc file in MonoSprites/Help/.

Lisence

MonoGame-Sprites is distributed with the permissive MIT License. For more info, check out the LICENSE file in this repo.

monogame-sprites's People

Contributors

ronenness avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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