示例#1
0
        public override void RemoveChild(CCNode child, bool cleanup)
        {
            if (child == null)
            {
                return;
            }

            Debug.Assert(child is CCParticleSystem,
                         "CCParticleBatchNode only supports CCQuadParticleSystems as children");
            Debug.Assert(Children.Contains(child), "CCParticleBatchNode doesn't contain the sprite. Can't remove it");

            CCParticleSystem pChild = (CCParticleSystem)child;

            // remove child helper
            TextureAtlas.RemoveQuadsAtIndex(pChild.AtlasIndex, pChild.TotalParticles);

            // after memmove of data, empty the quads at the end of array
            TextureAtlas.FillWithEmptyQuadsFromIndex(TextureAtlas.TotalQuads, pChild.TotalParticles);

            // particle could be reused for self rendering
            pChild.BatchNode = null;

            // Need to remove child from list of children before we update atlas indices
            base.RemoveChild(pChild, cleanup);

            UpdateAllAtlasIndexes();
        }
示例#2
0
        void InsertChild(CCParticleSystem pSystem, int index, int tag)
        {
            pSystem.AtlasIndex = index;

            if (TextureAtlas.TotalQuads + pSystem.TotalParticles > TextureAtlas.Capacity)
            {
                IncreaseAtlasCapacityTo(TextureAtlas.TotalQuads + pSystem.TotalParticles);

                // after a realloc empty quads of textureAtlas can be filled with gibberish (realloc doesn't perform calloc), insert empty quads to prevent it
                TextureAtlas.FillWithEmptyQuadsFromIndex(TextureAtlas.Capacity - pSystem.TotalParticles,
                                                         pSystem.TotalParticles);
            }

            // make room for quads, not necessary for last child
            if (pSystem.AtlasIndex + pSystem.TotalParticles != TextureAtlas.TotalQuads)
            {
                TextureAtlas.MoveQuadsFromIndex(index, index + pSystem.TotalParticles);
            }

            // increase totalParticles here for new particles, update method of particlesystem will fill the quads
            TextureAtlas.IncreaseTotalQuadsWith(pSystem.TotalParticles);

            UpdateAllAtlasIndexes();
        }