Example #1
0
        public override void OnEnter()
        {
            base.OnEnter();

            Color = new CCColor3B(0, 0, 0);
            RemoveChild(m_background, true);
            m_background = null;

            m_emitter = new CCParticleSystemQuad();
            m_emitter.InitWithTotalParticles(100);
            AddChild(m_emitter, 10);
            m_emitter.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire");

            // duration
            m_emitter.Duration = CCParticleSystem.kCCParticleDurationInfinity;

            // radius mode
            m_emitter.EmitterMode = CCEmitterMode.kCCParticleModeRadius;

            // radius mode: start and end radius in pixels
            m_emitter.StartRadius = (50);
            m_emitter.StartRadiusVar = (0);
            m_emitter.EndRadius = (CCParticleSystem.kCCParticleStartRadiusEqualToEndRadius);
            m_emitter.EndRadiusVar = (0);

            // radius mode: degrees per second
            m_emitter.RotatePerSecond = (0);
            m_emitter.RotatePerSecondVar = (0);

            // angle
            m_emitter.Angle = 90;
            m_emitter.AngleVar = 0;

            // emitter position
            CCSize size = CCDirector.SharedDirector.WinSize;
            m_emitter.Position = new CCPoint(size.Width / 2, size.Height / 2);
            m_emitter.PosVar = new CCPoint(0, 0);

            // life of particles
            m_emitter.Life = 5;
            m_emitter.LifeVar = 0;

            // spin of particles
            m_emitter.StartSpin = 0;
            m_emitter.StartSpinVar = 0;
            m_emitter.EndSpin = 0;
            m_emitter.EndSpinVar = 0;

            // color of particles
            var startColor = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f);
            m_emitter.StartColor = startColor;

            var startColorVar = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f);
            m_emitter.StartColorVar = startColorVar;

            var endColor = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f);
            m_emitter.EndColor = endColor;

            var endColorVar = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f);
            m_emitter.EndColorVar = endColorVar;

            // size, in pixels
            m_emitter.StartSize = 16;
            m_emitter.StartSizeVar = 0;
            m_emitter.EndSize = CCParticleSystem.kCCParticleStartSizeEqualToEndSize;

            // emits per second
            m_emitter.EmissionRate = m_emitter.TotalParticles / m_emitter.Life;

            // additive
            m_emitter.BlendAdditive = false;

            CCRotateBy rot = new CCRotateBy (16, 360);
            m_emitter.RunAction(new CCRepeatForever (rot));
        }