Code Monkey home page Code Monkey logo

projectiso-pixi-particles's Introduction

MonoGame Pixi Particles

A particle system for the MonoGame library, ported to C# from Pixi-Particles

Original system made by CloudKid

Also, see the interactive particle editor to design and preview custom particle emitters.

Alt text

Basic Usage

In load

particleTexture1 = Content.Load<Texture2D>("particle");
particleTexture2 = Content.Load<Texture2D>("fire");

particleContainer = new Container();
var config = new EmitterConfig(LoadJSON("./Content/emitter.json"));

particleEmitter = new Emitter(particleContainer, new TextureRegion2D[] {
    new TextureRegion2D(particleTexture1),
    new TextureRegion2D(particleTexture2)},
    config);

var x = Window.ClientBounds.Width * 0.5f;
var y = Window.ClientBounds.Height - 20f;

particleEmitter.UpdateOwnerPos(x, y);
particleEmitter.Emit = true;

In draw

var particles = particleContainer.Children;

spriteBatch.Begin();
for (int i = 0; i < particles.Count; i++)
{
    var particle = (Sprite)particles[i];

    if (GraphicsDevice.BlendState != particle.Material.blendState)
        GraphicsDevice.BlendState = particle.Material.blendState;

    Vector2 origin = new Vector2(particle.TextureRegion.Size.X * particle.Anchor.X - particle.TextureRegion.Trim.X,
        particle.TextureRegion.Size.Y * particle.Anchor.Y - particle.TextureRegion.Trim.Y);

    spriteBatch.Draw(
        particle.TextureRegion.BaseTexture,
        particle.Position,
        particle.TextureRegion.Frame,
        particle.Tint * (particle.Alpha * particleContainer.Alpha),
        particle.Rotation,
        origin,
        particle.Scale,
        SpriteEffects.None,
        0
    );
}
spriteBatch.End();

Documentation

Original docs should be fine for reference, just use PascalCase instead of camelCase where appropriate.

http://pixijs.github.io/pixi-particles/docs/

License

Copyright (c) 2019 Playerthree

Released under the MIT License.

projectiso-pixi-particles's People

Contributors

owlzy avatar veslo5 avatar pixelhugger 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.