Пример #1
0
        public static CCParticleSystem particleWithFile(string plistFile)
        {
            CCParticleSystem system = new CCParticleSystem();

            if ((system != null) && system.initWithFile(plistFile))
            {
                return(system);
            }
            return(system);
        }
Пример #2
0
        public static CCParticleSystem particleWithDictionary(Dictionary <string, object> dic)
        {
            CCParticleSystem system = new CCParticleSystem();

            if ((system != null) && system.initWithDictionary(dic))
            {
                return(system);
            }
            return(system);
        }
Пример #3
0
 /** creates an initializes a CCParticleSystem from a plist file.
 This plist files can be creted manually or with Particle Designer:
 http://particledesigner.71squared.com/
 @since v0.99.3
 */
 public static CCParticleSystem particleWithFile(string plistFile)
 {
     CCParticleSystem pRet = new CCParticleSystem();
     if (null != pRet && pRet.initWithFile(plistFile))
     {
         return pRet;
     }
     return pRet;
 }
Пример #4
0
        public ParticleDemo()
        {
            initWithColor( ccTypes.ccc4(127,127,127,255) );

            m_emitter = null;

            isTouchEnabled = true;

            CCSize s = CCDirector.sharedDirector().getWinSize();
            CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 28);
            addChild(label, 100, 1000);
            label.position = new CCPoint(s.width/2, s.height-50);

            CCLabelTTF tapScreen = CCLabelTTF.labelWithString("(Tap the Screen)", "Arial", 20);
            tapScreen.position = new CCPoint(s.width/2, s.height-80);
            addChild(tapScreen, 100);

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

            CCMenuItemToggle item4 = CCMenuItemToggle.itemWithTarget(	this,
                                                                        new SEL_MenuHandler(toggleCallback),
                                                                        CCMenuItemFont.itemFromString( "Free Movement" ),
                                                                        CCMenuItemFont.itemFromString( "Relative Movement" ),
                                                                        CCMenuItemFont.itemFromString( "Grouped Movement" ));

            CCMenu menu = CCMenu.menuWithItems(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 = CCLabelAtlas.labelWithString("0000", "fonts/fnt/images/fps_images", 16, 24, '.');
            addChild(labelAtlas, 100, ParticleTestScene.kTagLabelAtlas);
            labelAtlas.position = new CCPoint(s.width-66,50);

            // moving background
            m_background = CCSprite.spriteWithFile(TestResource.s_back3);
            addChild(m_background, 5);
            m_background.position = new CCPoint(s.width/2 - 120, s.height - 240);

            CCActionInterval move = CCMoveBy.actionWithDuration(4, new CCPoint(300,0) );
            CCFiniteTimeAction move_back = move.reverse();
            CCFiniteTimeAction seq = CCSequence.actions(move, move_back);
            m_background.runAction( CCRepeatForever.actionWithAction((CCActionInterval)seq) );

            schedule( new SEL_SCHEDULE(step) );
        }
Пример #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, 1000);
            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 = CCMenuItemToggle.Create(toggleCallback,
                                                                     CCMenuItemFont.Create("Free Movement"),
                                                                     CCMenuItemFont.Create("Relative Movement"),
                                                                     CCMenuItemFont.Create("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;
            try
            {
                labelAtlas = CCLabelAtlas.Create("0000", "Images/fps_Images", 16, 24, '.');
            }
            catch (Exception)
            {
                labelAtlas = CCLabelAtlas.Create("0000", "Images/fps_Images", 16, 24, '.');
            }
            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 = CCSequence.FromActions(move, move_back);
            m_background.RunAction(new CCRepeatForever ((CCActionInterval) seq));

            Schedule(step);
        }
Пример #6
0
 public static CCParticleSystem Create(string plistFile)
 {
     var pRet = new CCParticleSystem();
     if (pRet.InitWithFile(plistFile))
     {
         return pRet;
     }
     return null;
 }
Пример #7
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();
        }
Пример #8
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 RawList<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_bIsRunning)
            {
                child.OnEnter();
                child.OnEnterTransitionDidFinish();
            }
            return pos;
        }
Пример #9
0
        void SetUpParticleSystemSun()
        {
            //recommended for iPad only

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

            particleSystemStartPosition = system.Position;
        }