Beispiel #1
0
        public override void onEnter()
        {
            base.onEnter();

            // rotate and jump
            CCActionInterval jump1 = CCJumpBy.actionWithDuration(4, new CCPoint(-400, 0), 100, 4);
            CCActionInterval jump2 = jump1.reverse() as CCActionInterval;
            CCActionInterval rot1  = CCRotateBy.actionWithDuration(4, 360 * 2);
            CCActionInterval rot2  = rot1.reverse() as CCActionInterval;

            CCFiniteTimeAction seq3_1 = CCSequence.actions(jump2, jump1);
            CCFiniteTimeAction seq3_2 = CCSequence.actions(rot1, rot2);
            CCFiniteTimeAction spawn  = CCSpawn.actions(seq3_1, seq3_2);
            CCFiniteTimeAction action = CCRepeatForever.actionWithAction((CCActionInterval)spawn);

            CCRepeatForever action2 = (CCRepeatForever)(action.copy());
            CCRepeatForever action3 = (CCRepeatForever)(action.copy());


            m_grossini.runAction(CCSpeed.actionWithAction((CCActionInterval)action, 0.5f));
            m_tamara.runAction(CCSpeed.actionWithAction((CCActionInterval)action2, 1.5f));
            m_kathia.runAction(CCSpeed.actionWithAction((CCActionInterval)action3, 1.0f));

            CCParticleSystem emitter = CCParticleFireworks.node();

            emitter.Texture = CCTextureCache.sharedTextureCache().addImage("Images/fire");
            addChild(emitter);
        }
Beispiel #2
0
        public void createParticles()
        {
            _jet = new CCParticleSystemQuad("jet.plist");
            _jet.SourcePosition = new CCPoint(-_rocket._radius * 0.8f, 0);
            _jet.Angle          = 180;
            _jet.StopSystem();
            AddChild(_jet, kBackground);

            _boom = new CCParticleSystemQuad("boom.plist");
            _boom.StopSystem();
            AddChild(_boom, kForeground);

            _comet = new CCParticleSystemQuad("comet.plist");
            _comet.StopSystem();
            _comet.Position = new CCPoint(0, _screenSize.Height * 0.6f);
            _comet.Visible  = false;
            AddChild(_comet, kForeground);

            _pickup = new CCParticleSystemQuad("plink.plist");
            _pickup.StopSystem();
            AddChild(_pickup, kMiddleground);

            _warp          = new CCParticleSystemQuad("warp.plist");
            _warp.Position = _rocket.Position;
            AddChild(_warp, kBackground);

            _star = new CCParticleSystemQuad("star.plist");
            _star.StopSystem();
            _star.Visible = false;
            AddChild(_star, kBackground, kSpriteStar);
        }
        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));
        }
Beispiel #4
0
        public void step(float dt)
        {
            CCLabelAtlas     atlas   = (CCLabelAtlas)GetChildByTag(PerformanceParticleTest.kTagLabelAtlas);
            CCParticleSystem emitter = (CCParticleSystem)GetChildByTag(PerformanceParticleTest.kTagParticleSystem);

            var str = string.Format("{0:0000}", emitter.ParticleCount);

            atlas.Text = (str);
        }
        public void step(float dt)
        {
            CCLabelAtlas     atlas   = (CCLabelAtlas)getChildByTag(PerformanceParticleTest.kTagLabelAtlas);
            CCParticleSystem emitter = (CCParticleSystem)getChildByTag(PerformanceParticleTest.kTagParticleSystem);

            //char str[10] = {0};
            string str;

            //sprintf(str, "%4d", emitter->getParticleCount());
            str = string.Format("{0:D4}", emitter.ParticleCount);
            atlas.setString(str);
        }
Beispiel #6
0
        void Explode(CCPoint pt)
        {
            if (explosion != null)
            {
                this.RemoveChild(explosion);
                explosion = null;
            }

            explosion = new CCParticleExplosion(pt);
            explosion.TotalParticles     = 10;
            explosion.AutoRemoveOnFinish = true;

            AddChild(explosion);
        }
Beispiel #7
0
        void p2(CCPoint pos)
        {
            if (part != null)
            {
                part.RemoveFromParent();
                part = null;
            }

            part                    = new CCParticleSystemQuad("particle_texture.plist");
            part.Position           = pos;
            part.AutoRemoveOnFinish = true; //??

            part.ScheduleOnce((x) => {
                part.RemoveFromParent();
                part = null;
            }, 1f);

            AddChild(part);
        }
Beispiel #8
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            CCRect  visibleBounds     = VisibleBoundsWorldspace;
            CCPoint centerBounds      = visibleBounds.Center;
            CCPoint quarterWidthDelta = new CCPoint(visibleBounds.Size.Width / 4.0f, 0.0f);

            // Layout the positioning of sprites based on visibleBounds
            monkeySprite1.AnchorPoint = CCPoint.AnchorMiddle;
            monkeySprite1.Position    = centerBounds + quarterWidthDelta;

            monkeySprite2.AnchorPoint = CCPoint.AnchorMiddle;
            monkeySprite2.Position    = centerBounds - quarterWidthDelta;

            // Run actions on sprite
            // Note: we can reuse the same action definition on multiple sprites!
            monkeySprite1.RunAction(new CCSequence(dreamAction, repeatedAction));
            monkeySprite2.RunAction(new CCSequence(dreamAction, new CCDelayTime(0.5f), repeatedAction));

            // Create preloaded galaxy particle system
            galaxySystem = new CCParticleGalaxy(centerBounds);

            // Customise default behaviour of predefined particle system
            galaxySystem.EmissionRate = 20.0f;
            galaxySystem.EndSize      = 3.0f;
            galaxySystem.EndRadius    = visibleBounds.Size.Width;
            galaxySystem.Life         = 10.0f;

            AddChild(galaxySystem, 0);

            // Register to touch event
            var touchListener = new CCEventListenerTouchAllAtOnce();

            touchListener.OnTouchesEnded = OnTouchesEnded;
            AddEventListener(touchListener, this);
        }
Beispiel #9
0
        public override void doTest()
        {
            CCSize           s = CCDirector.sharedDirector().getWinSize();
            CCParticleSystem particleSystem = (CCParticleSystem)getChildByTag(PerformanceParticleTest.kTagParticleSystem);

            // duration
            particleSystem.Duration = -1;

            // gravity
            particleSystem.setGravity(new CCPoint(0, -90));

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

            // radial
            particleSystem.setRadialAccel(0);
            particleSystem.setRadialAccelVar(0);

            // speed of particles
            particleSystem.setSpeed(180);
            particleSystem.setSpeedVar(50);

            // emitter position
            particleSystem.position = new CCPoint(s.width / 2, 100);
            particleSystem.PosVar   = new CCPoint(s.width / 2, 0);

            // life of particles
            particleSystem.Life    = 2.0f;
            particleSystem.LifeVar = 1;

            // emits per frame
            particleSystem.EmissionRate = particleSystem.TotalParticles / particleSystem.Life;

            // color of particles
            ccColor4F startColor = new ccColor4F {
                r = 0.5f, g = 0.5f, b = 0.5f, a = 1.0f
            };

            particleSystem.StartColor = startColor;

            ccColor4F startColorVar = new ccColor4F {
                r = 0.5f, g = 0.5f, b = 0.5f, a = 1.0f
            };

            particleSystem.StartColor = startColorVar;

            ccColor4F endColor = new ccColor4F {
                r = 0.1f, g = 0.1f, b = 0.1f, a = 0.2f
            };

            particleSystem.EndColor = endColor;

            ccColor4F endColorVar = new ccColor4F {
                r = 0.1f, g = 0.1f, b = 0.1f, a = 0.2f
            };

            particleSystem.EndColorVar = endColorVar;

            // size, in pixels
            particleSystem.EndSize      = 8.0f;
            particleSystem.StartSize    = 8.0f;
            particleSystem.EndSizeVar   = 0;
            particleSystem.StartSizeVar = 0;

            // additive
            particleSystem.IsBlendAdditive = false;
        }
Beispiel #10
0
        public override void doTest()
        {
            CCSize           s = CCDirector.SharedDirector.WinSize;
            CCParticleSystem particleSystem = (CCParticleSystem)GetChildByTag(PerformanceParticleTest.kTagParticleSystem);

            // duration
            particleSystem.Duration = -1;

            // gravity
            particleSystem.Gravity = (new CCPoint(0, -90));

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

            // radial
            particleSystem.RadialAccel    = (0);
            particleSystem.RadialAccelVar = (0);

            // speed of particles
            particleSystem.Speed    = (180);
            particleSystem.SpeedVar = (50);

            // emitter position
            particleSystem.Position = new CCPoint(s.Width / 2, 100);
            particleSystem.PosVar   = new CCPoint(s.Width / 2, 0);

            // life of particles
            particleSystem.Life    = 2.0f;
            particleSystem.LifeVar = 1;

            // emits per frame
            particleSystem.EmissionRate = particleSystem.TotalParticles / particleSystem.Life;

            // color of particles
            CCColor4F startColor = new CCColor4F {
                R = 0.5f, G = 0.5f, B = 0.5f, A = 1.0f
            };

            particleSystem.StartColor = startColor;

            CCColor4F startColorVar = new CCColor4F {
                R = 0.5f, G = 0.5f, B = 0.5f, A = 1.0f
            };

            particleSystem.StartColorVar = startColorVar;

            CCColor4F endColor = new CCColor4F {
                R = 0.1f, G = 0.1f, B = 0.1f, A = 0.2f
            };

            particleSystem.EndColor = endColor;

            CCColor4F endColorVar = new CCColor4F {
                R = 0.1f, G = 0.1f, B = 0.1f, A = 0.2f
            };

            particleSystem.EndColorVar = endColorVar;

            // size, in pixels
            particleSystem.EndSize      = 64.0f;
            particleSystem.StartSize    = 64.0f;
            particleSystem.EndSizeVar   = 0;
            particleSystem.StartSizeVar = 0;

            // additive
            particleSystem.BlendAdditive = false;
        }
        public void createParticleSystem()
        {
            CCParticleSystem particleSystem = null;

            /*
             * Tests:
             * 1: Point Particle System using 32-bit textures (PNG)
             * 2: Point Particle System using 16-bit textures (PNG)
             * 3: Point Particle System using 8-bit textures (PNG)
             * 4: Point Particle System using 4-bit textures (PVRTC)
             *
             * 5: Quad Particle System using 32-bit textures (PNG)
             * 6: Quad Particle System using 16-bit textures (PNG)
             * 7: Quad Particle System using 8-bit textures (PNG)
             * 8: Quad Particle System using 4-bit textures (PVRTC)
             */
            removeChildByTag(PerformanceParticleTest.kTagParticleSystem, true);

            // remove the "fire.png" from the TextureCache cache.
            CCTexture2D texture = CCTextureCache.sharedTextureCache().addImage("Images/fire");

            CCTextureCache.sharedTextureCache().removeTexture(texture);

            if (subtestNumber <= 3)
            {
                particleSystem = new CCParticleSystemPoint();
            }
            else
            {
                particleSystem = new CCParticleSystemQuad();
            }

            switch (subtestNumber)
            {
            case 1:
                CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888);
                particleSystem.initWithTotalParticles((uint)quantityParticles);
                particleSystem.Texture = CCTextureCache.sharedTextureCache().addImage("Images/fire");
                break;

            case 2:
                CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA4444);
                particleSystem.initWithTotalParticles((uint)quantityParticles);
                particleSystem.Texture = CCTextureCache.sharedTextureCache().addImage("Images/fire");
                break;

            case 3:
                CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_A8);
                particleSystem.initWithTotalParticles((uint)quantityParticles);
                particleSystem.Texture = CCTextureCache.sharedTextureCache().addImage("Images/fire");
                break;

            //     case 4:
            //         particleSystem->initWithTotalParticles(quantityParticles);
            //         ////---- particleSystem.texture = [[CCTextureCache sharedTextureCache] addImage:@"fire.pvr"];
            //         particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png"));
            //         break;
            case 4:
                CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888);
                particleSystem.initWithTotalParticles((uint)quantityParticles);
                particleSystem.Texture = CCTextureCache.sharedTextureCache().addImage("Images/fire");
                break;

            case 5:
                CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA4444);
                particleSystem.initWithTotalParticles((uint)quantityParticles);
                particleSystem.Texture = CCTextureCache.sharedTextureCache().addImage("Images/fire");
                break;

            case 6:
                CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_A8);
                particleSystem.initWithTotalParticles((uint)quantityParticles);
                particleSystem.Texture = CCTextureCache.sharedTextureCache().addImage("Images/fire");
                break;

            //     case 8:
            //         particleSystem->initWithTotalParticles(quantityParticles);
            //         ////---- particleSystem.texture = [[CCTextureCache sharedTextureCache] addImage:@"fire.pvr"];
            //         particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png"));
            //         break;
            default:
                particleSystem = null;
                CCLog.Log("Shall not happen!");
                break;
            }
            addChild(particleSystem, 0, PerformanceParticleTest.kTagParticleSystem);

            doTest();

            // restore the default pixel format
            CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888);
        }
Beispiel #12
0
        public void createParticlesAsync()
        {
            isLoading = true;


            var label = new CCLabelTtf("Loading...", "MarkerFelt", 22);

            label.Position = _screenSize.Center;
            label.Position = new CCPoint(_screenSize.Center.X, _screenSize.Height * 0.75f);

            label.Visible = false;
            label.Name    = "Loading";
            AddChild(label, 10);

            var scale = new CCScaleBy(0.3f, 2);

            label.RunActions(new CCDelayTime(1.0f), new CCShow());
            label.RepeatForever(scale, scale.Reverse());



            CCParticleSystemCache.SharedParticleSystemCache.AddParticleSystemAsync("jet.plist",

                                                                                   (jetConfig) =>
            {
                _jet = new CCParticleSystemQuad(jetConfig);
                _jet.SourcePosition = new CCPoint(-_rocket._radius * 0.8f, 0);
                _jet.Angle          = 180;
                _jet.StopSystem();
                AddChild(_jet, kBackground);

                loadedParticleSystems++;
                updateLoading();
            });

            CCParticleSystemCache.SharedParticleSystemCache.AddParticleSystemAsync("boom.plist",

                                                                                   (boomConfig) =>
            {
                _boom = new CCParticleSystemQuad(boomConfig);
                _boom.StopSystem();
                AddChild(_boom, kForeground);
                loadedParticleSystems++;
                updateLoading();
            });

            CCParticleSystemCache.SharedParticleSystemCache.AddParticleSystemAsync("comet.plist",

                                                                                   (cometConfig) =>
            {
                _comet = new CCParticleSystemQuad(cometConfig);
                _comet.StopSystem();
                _comet.Position = new CCPoint(0, _screenSize.Height * 0.6f);
                _comet.Visible  = false;
                AddChild(_comet, kForeground);
                loadedParticleSystems++;
                updateLoading();
            });


            CCParticleSystemCache.SharedParticleSystemCache.AddParticleSystemAsync("star.plist",

                                                                                   (starConfig) =>
            {
                _star = new CCParticleSystemQuad(starConfig);
                _star.StopSystem();
                _star.Visible = false;
                AddChild(_star, kBackground, kSpriteStar);
                loadedParticleSystems++;
                updateLoading();
            });

            CCParticleSystemCache.SharedParticleSystemCache.AddParticleSystemAsync("plink.plist",

                                                                                   (plinkConfig) =>
            {
                _pickup = new CCParticleSystemQuad(plinkConfig);
                _pickup.StopSystem();
                AddChild(_pickup, kMiddleground);
                loadedParticleSystems++;
                updateLoading();
            });


            CCParticleSystemCache.SharedParticleSystemCache.AddParticleSystemAsync("warp.plist",

                                                                                   (warpConfig) =>
            {
                _warp          = new CCParticleSystemQuad(warpConfig);
                _warp.Position = _rocket.Position;
                AddChild(_warp, kBackground);
                loadedParticleSystems++;
                updateLoading();
            });
        }
Beispiel #13
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            CCRect visibleBounds = VisibleBoundsWorldspace;

            XMaxValue = visibleBounds.MaxX;
            YMaxValue = visibleBounds.MaxY;

            XMinValue = visibleBounds.MinX;
            YMinValue = visibleBounds.MinY;

            CCPoint centerBounds = visibleBounds.Center;

            //CCPoint quarterWidthDelta = new CCPoint (visibleBounds.Size.Width / 4.0f, 0.0f);

            // Layout the positioning of sprites based on visibleBounds
            //monkeySprite1.AnchorPoint = CCPoint.AnchorMiddle;
            //	monkeySprite1.Position = centerBounds + quarterWidthDelta;

            //	monkeySprite2.AnchorPoint = CCPoint.AnchorMiddle;
            //	monkeySprite2.Position = centerBounds - quarterWidthDelta;

            //floorClone.AnchorPoint = CCPoint.AnchorUpperRight;

            positionSprites();

            tunnel2.RotationX = tunnel2.RotationX - 180f;
            tunnel2.RotationY = tunnel2.RotationY - 180f;


            tunnel3.RotationX = tunnel3.RotationX - 90f;
            tunnel3.RotationY = tunnel3.RotationY - 90f;

            tunnel4.RotationX = tunnel4.RotationX - 270f;
            tunnel4.RotationY = tunnel4.RotationY - 270f;

            // Run actions on sprite
            // Note: we can reuse the same action definition on multiple sprites!
            //	monkeySprite1.RunAction (new CCSequence (dreamAction, repeatedAction));
            //	monkeySprite2.RunAction (new CCSequence (dreamAction, new CCDelayTime (0.5f), repeatedAction));

            //hero.RunAction (repeatedAction);

            // Create preloaded galaxy particle system
            galaxySystem = new CCParticleGalaxy(centerBounds);

            // Customise default behaviour of predefined particle system
            galaxySystem.EmissionRate = 20.0f;
            galaxySystem.EndSize      = 1.0f;
            galaxySystem.EndRadius    = visibleBounds.Size.Width;
            galaxySystem.Life         = 10.0f;
            galaxySystem.Color        = CCColor3B.Red;

            //	AddChild (galaxySystem, 0);

            // Register to touch event
            var touchListener = new CCEventListenerTouchAllAtOnce();

            touchListener.OnTouchesEnded = OnTouchesEnded;
            AddEventListener(touchListener, this);
        }