Ejemplo n.º 1
0
        // don't use lazy sorting, reordering the particle systems quads afterwards would be too complex
        // XXX research whether lazy sorting + freeing current quads and calloc a new block with size of capacity would be faster
        // XXX or possibly using vertexZ for reordering, that would be fastest
        // this helper is almost equivalent to CCNode's addChild, but doesn't make use of the lazy sorting
        private int AddChildHelper(CCParticleSystem child, int z, int aTag)
        {
            Debug.Assert(child != null, "Argument must be non-nil");
            Debug.Assert(child.Parent == null, "child already added. It can't be added again");

            if (m_pChildren == null)
            {
                m_pChildren = new CCRawList <CCNode>(4);
            }

            //don't use a lazy insert
            int pos = SearchNewPositionInChildrenForZ(z);

            m_pChildren.Insert(pos, child);

            child.Tag       = aTag;
            child.m_nZOrder = z;

            child.Parent = this;

            if (m_bRunning)
            {
                child.OnEnter();
                child.OnEnterTransitionDidFinish();
            }
            return(pos);
        }
Ejemplo n.º 2
0
        // CCParticleBatchNode - add / remove / reorder helper methods

        // add child helper
        private void InsertChild(CCParticleSystem pSystem, int index)
        {
            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();
        }
Ejemplo n.º 3
0
        // CCParticleBatchNode - add / remove / reorder helper methods

        // add child helper
        private 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();
        }
Ejemplo n.º 4
0
        // don't use lazy sorting, reordering the particle systems quads afterwards would be too complex
        // XXX research whether lazy sorting + freeing current quads and calloc a new block with size of capacity would be faster
        // XXX or possibly using vertexZ for reordering, that would be fastest
        // this helper is almost equivalent to CCNode's addChild, but doesn't make use of the lazy sorting
        private int AddChildHelper(CCParticleSystem child, int z, int aTag)
        {
            Debug.Assert(child != null, "Argument must be non-nil");
            Debug.Assert(child.Parent == null, "child already added. It can't be added again");

            if (m_pChildren == null)
            {
                m_pChildren = new CCRawList<CCNode>(4);
            }

            //don't use a lazy insert
            int pos = SearchNewPositionInChildrenForZ(z);

            m_pChildren.Insert(pos, child);

            child.Parent = this;

            child.Tag = aTag;
            child.m_nZOrder = z;

            if (m_bRunning)
            {
                child.OnEnter();
                child.OnEnterTransitionDidFinish();
            }
            return pos;
        }
Ejemplo n.º 5
0
        public ParticleDemo()
        {
            InitWithColor(CCTypes.CreateColor(127, 127, 127, 255));

            m_emitter = null;

            TouchEnabled = true;

            CCSize s = CCDirector.SharedDirector.WinSize;
            CCLabelTTF label = new CCLabelTTF(title(), "arial", 28);
            AddChild(label, 100, kLabelTag);
            label.Position = new CCPoint(s.Width / 2, s.Height - 50);

            CCLabelTTF tapScreen = new CCLabelTTF(subtitle(), "arial", 20);
            tapScreen.Position = new CCPoint(s.Width / 2, s.Height - 80);
            AddChild(tapScreen, 100);

            CCMenuItemImage item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback);

            CCMenuItemToggle item4 = new CCMenuItemToggle(toggleCallback,
                                                                     new CCMenuItemFont("Free Movement"),
                                                                     new CCMenuItemFont("Relative Movement"),
                                                                     new CCMenuItemFont("Grouped Movement"));

            CCMenu menu = new CCMenu(item1, item2, item3, item4);

            menu.Position = new CCPoint(0, 0);
            item1.Position = new CCPoint(s.Width / 2 - 100, 30);
            item2.Position = new CCPoint(s.Width / 2, 30);
            item3.Position = new CCPoint(s.Width / 2 + 100, 30);
            item4.Position = new CCPoint(0, 100);
            item4.AnchorPoint = new CCPoint(0, 0);

            AddChild(menu, 100);

            CCLabelAtlas labelAtlas = new CCLabelAtlas("0000", "Images/fps_Images", 12, 32, '.');
            AddChild(labelAtlas, 100, ParticleTestScene.kTagLabelAtlas);
            labelAtlas.Position = new CCPoint(s.Width - 66, 50);

            // moving background
            m_background = new CCSprite(TestResource.s_back3);
            AddChild(m_background, 5);
            m_background.Position = new CCPoint(s.Width / 2, s.Height - 180);

            CCActionInterval move = new CCMoveBy (4, new CCPoint(300, 0));
            CCFiniteTimeAction move_back = move.Reverse();
            CCFiniteTimeAction seq = new CCSequence(move, move_back);
            m_background.RunAction(new CCRepeatForever ((CCActionInterval) seq));

            Schedule(step);
        }
Ejemplo n.º 6
0
        void SetUpParticleSystemSun()
        {
            //recommended for iPad only

            system = new CCParticleSun ();
            // AddChild(system, Constants.depthParticles);
            system.Scale = 3;
            system.Position = new CCPoint(240, 400 );

            particleSystemStartPosition = system.Position;
        }