예제 #1
0
        public void RunParticleTick()
        {
            // Loop through all the emitters and update accordingly:
            for (int i = 0; i < this.emitterList.Count; i++)
            {
                IEmitter emitter = this.emitterList[i];

                // Remove the emitter when it's time has expired.
                // NOTE: The Emitter removes itself from the pool on this frame in RunEmitterTick();
                if (emitter.HasExpired)
                {
                    this.emitterList.Remove(emitter);
                    i--;
                }

                emitter.RunEmitterTick();
            }

            // Loop through all free particles (ones that aren't attached to emitters)
            for (int i = 0; i < this.freeParticles.Count; i++)
            {
                ParticleFree particle = this.freeParticles[i];

                // Remove Free Particles as applicable:
                if (particle.HasExpired)
                {
                    this.freeParticles.Remove(particle);
                    i--;
                }

                particle.RunParticleTick();
            }
        }
예제 #2
0
        public static ParticleFree SetParticle(RoomScene room, Atlas atlas, string spriteName, Vector2 pos, Vector2 vel, int frameEnd, int fadeStart = 0, float alphaStart = 1, float alphaEnd = 0, float rotation = 0, float rotationSpeed = 0, float gravity = 0)
        {
            // Retrieve an available particle from the pool.
            ParticleFree particle = ParticleFree.pool.GetObject();

            particle.atlas         = atlas;
            particle.spriteName    = spriteName;
            particle.gravity       = gravity;
            particle.pos           = pos;
            particle.vel           = vel;
            particle.frameEnd      = frameEnd;
            particle.fadeStart     = fadeStart == 0 ? frameEnd + 1 : fadeStart;
            particle.alphaStart    = alphaStart;
            particle.alphaEnd      = alphaEnd;
            particle.rotation      = rotation;
            particle.rotationSpeed = rotationSpeed;

            // Add the Particle to the Particle Handler
            room.particleHandler.AddParticle(particle);

            return(particle);
        }
예제 #3
0
 public void AddParticle(ParticleFree particle)
 {
     this.freeParticles.Add(particle);
 }