public void AddEmitterGroup(EmitterGroup group) { _groups.Add(group.Name, group); foreach (Modifier mod in _modifiers) { group.ApplyModifier(mod); } }
//======================================================[ Constructors & Methods ] public ParticleSystem(Game game) : base(game) { _groups = new Dictionary<string, EmitterGroup>(); _modifiers = new List<Modifier>(); _strips = new Dictionary<string, ImageStrip>(); _trans = new Stack<Vector2>(); ImageStrip strip = new ImageStrip("Default"); strip.Asset = @"Resources\MPEDefaultParticle"; strip.FrameWidth = strip.FrameHeight = 32; strip.Frames = 2; _strips.Add("Default", strip); EmitterGroup group = new EmitterGroup("Default"); _groups.Add("Default", group); game.Components.Add(this); }
protected override void Initialize() { //Creating the EmitterGroup, it must be given a name. group = new EmitterGroup("test"); //Create two simple spray emitters. emitter1 = new SprayEmitter(1000, -MathHelper.PiOver2, MathHelper.Pi); emitter1.ParticleSpeed = 100f; emitter1.ParticleColor = Color.SteelBlue; emitter1.Position.Y = -50f; emitter2 = new SprayEmitter(1000, MathHelper.PiOver2, MathHelper.Pi); emitter2.ParticleSpeed = 100f; emitter2.ParticleColor = Color.Tomato; emitter2.Position.Y = 50f; //We add the Emitters to the EmitterGroup (instead of adding them to the //ParticleSystem). group.AddEmitter(emitter1); group.AddEmitter(emitter2); //Now we can apply Modifiers to the EmitterGroup. Notice that there is a //seperate Modifier for GroupMouseController. As the position of Emitters is //relative to the position of the EmitterGroup, applying a regalar //EmitterMouseController would result in undesired results... This modifier //adjusts the position of the EmitterGroup, and not the Emitters. group.ApplyModifier(new RandomScaleModifier(.1f, 1f)); group.ApplyModifier(new GroupMouseController(true)); //Finally we add the EmitterGroup to the ParticleSystem. system.AddEmitterGroup(group); //Of course you can choose to ignore EmitterGroups, and add Emitters to the //ParticleSystem directly instead. However you should take care to never //add an Emitter to more than one container. base.Initialize(); }