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.
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();
Original docs should be fine for reference, just use PascalCase instead of camelCase where appropriate.
https://pixijs.io/particle-emitter/docs/
Copyright (c) 2019 Playerthree
Released under the MIT License.