This example shows how to create a particle effect programmatically.

            ParticleEffect effect = new ParticleEffect()
            {
                Emitters = new EmitterCollection()
                {   
                    new SphereEmitter
                    {
                        Name="Flames",
                        Budget = 100,
                        Term = 0.5f,
                        ReleaseQuantity = 8,
                        Enabled = true,
                        ReleaseSpeed = new Range(5f,5f),
                        ReleaseColour = new ColourRange
                        {
                            Red = new Range(0.9f,1f),
                            Green = new Range(0.5f,0.5f),
                            Blue = new Range(0f,0f),
                        },
                        ReleaseOpacity = new Range(1f,1f),
                        ReleaseScale = new Range(2f,2f),
                        ReleaseRotation = new RotationRange
                        {
                            Pitch = new Range(0f,0f),
                            Yaw = new Range(0f,0f),
                            Roll = new Range(-3.14f,3.14f),
                        },
                        ParticleTexture = Core.Content.Load<Texture2D>("Textures\\Flame"),
                        BlendMode = EmitterBlendMode.Add,
                        Radius = 3f,
                        Shell = true,
                        Radiate = true,                        
                        BillboardStyle = ProjectMercury.BillboardStyle.Spherical,
                        Modifiers = new ModifierCollection
                        {
                            new OpacityInterpolator2
                            {
                                InitialOpacity = 0.5f,                                
                                FinalOpacity = 0f,
                            },
                            new RotationModifier
                            {
                                RotationRate = new Vector3(0,0,1)
                            }
                        },
                        Controllers = new ControllerPipeline
                        {
                            new CooldownController
                            {
                                CooldownPeriod = 0.02f,
                            },
                        }
                    }
                }
            };

            ParticleObject particle = new ParticleObject(Vector3.Up, effect);

Last edited Jan 23, 2013 at 3:11 PM by Izzo, version 1

Comments

No comments yet.