コード例 #1
0
        public void updateQuads(float dt)
        {
            m_nIndex = (m_nIndex + 1) % 4;
            CCRect rect = new CCRect(m_nIndex * 32, 0, 32, 32);
            CCParticleSystemQuad system = (CCParticleSystemQuad)m_emitter;

            system.setTextureWithRect(m_emitter.Texture, rect);
        }
コード例 #2
0
ファイル: GameLayer.cs プロジェクト: winiffercotes/Spacegame
        void AddStars(CCRect bounds)
        {
            var         stars   = new CCParticleSystemQuad("stars.plist");
            const float xOffset = 400.0f;

            stars.Position = new CCPoint(bounds.Center.X + xOffset, bounds.Center.Y);
            AddChild(stars);
        }
コード例 #3
0
 void InitExplosionParticles()
 {
     //BUG: the texture used in the particle system doesn't look correct on Android (probably due to premultiplied setting)
     explosion = new CCParticleSystemQuad("ExplodingBanana.plist");
     explosion.AutoRemoveOnFinish = false;
     explosion.StopSystem();
     explosion.Visible = false;
     AddChild(explosion);
 }
コード例 #4
0
        public MainSceneLayer()
        {
            SetupBackground();
            var starParticles = new CCParticleSystemQuad(@"Particles\bg-stars.plist");

            starParticles.SourcePosition = new CCPoint(CCDirector.SharedDirector.WinSize.Width / 2, CCDirector.SharedDirector.WinSize.Height / 2);
            starParticles.PosVar         = new CCPoint(CCDirector.SharedDirector.WinSize.Width / 2, CCDirector.SharedDirector.WinSize.Height / 2);
            AddChild(starParticles);

            CCMenuItemImage buttonPlay  = new CCMenuItemImage(@"MainScene\btn-play.png", @"MainScene\btn-play-down.png", OnPlayPressed);
            CCMenuItemImage buttonAbout = new CCMenuItemImage(@"MainScene\btn-about.png", @"MainScene\btn-about-down.png", OnAboutPressed);
            var             buttonLevel = new CCMenuItemImage(@"MainScene\btn-levels.png", @"MainScene\btn-levels-down.png", OnChooseLevelPressed);

            var scale = 1f;

#if WINDOWS_PHONE || ANDROID
            scale = 0.6f;
#endif
            buttonAbout.Scale   = buttonPlay.Scale = scale;
            buttonAbout.Opacity = buttonPlay.Opacity = 0;
            buttonLevel.Scale   = scale;
            buttonLevel.Opacity = 0;


            _buttonsMenu = new CCMenu(buttonPlay, buttonLevel, buttonAbout);
            _buttonsMenu.AlignItemsVerticallyWithPadding(20);

            buttonAbout.Scale = buttonPlay.Scale = buttonLevel.Scale = 0.01f;

            _logo             = new CCSprite(@"MainScene\logo.png");
            _logo.AnchorPoint = new CCPoint(0, 1);
            _logo.Scale       = 0.05f;
            _logo.Opacity     = 0;
            _logo.Position    = new CCPoint(24, CCDirector.SharedDirector.WinSize.Height - 24);
            AddChild(_logo);
            AddChild(_buttonsMenu);


            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("crystals.plist");
            Scheduler.ScheduleUpdateForTarget(this, 1, false);
            var scoreLabel = new CCLabelBMFont(LastScore.ToString(), @"Fonts\scorefont.fnt");
            scoreLabel.Position    = new CCPoint(CCDirector.SharedDirector.WinSize.Width / 2, 50);
            scoreLabel.AnchorPoint = new CCPoint(0.5f, 0f);

            var scoreLabelDescription = new CCLabelBMFont("ПОСЛЕДНИЙ СЧЕТ", @"Fonts\Foo64.fnt");
            scoreLabelDescription.Position    = new CCPoint(CCDirector.SharedDirector.WinSize.Width / 2, 55);
            scoreLabelDescription.AnchorPoint = new CCPoint(0.5f, 1f);
#if !ANDROID
            //CCSimpleAudioEngine.SharedEngine.PlayBackgroundMusic(@"Sounds\loop");
#endif

            AddChild(scoreLabelDescription);
            AddChild(scoreLabel);
        }
コード例 #5
0
ファイル: GameLayer.cs プロジェクト: capone212/cocotest
 void StarsFireworks(CCPoint pos)
 {
     try
     {
         var sparks = new CCParticleSystemQuad("sparks.plist");
         sparks.Position = pos;
         AddChild(sparks);
     }
     catch (Exception ex)
     {
         Log.Info("adyga_pazzle", "Can't add sparks to scene {0}", ex);
     }
 }
コード例 #6
0
        void InitExplosionParticles()
        {
            explosion = new CCParticleSystemQuad("ExplodingBanana.plist");
            explosion.AutoRemoveOnFinish = false;
            explosion.BlendFunc          = CCBlendFunc.Opaque;
#if ANDROID
            //The texture used in the particle system doesn't look correct on Android (probably due to premultiplied setting)
            // In the ExplodingBanana.plist configuration the Blending Funcion is set for Premulitplied Alpha so
            // we will overrid it for Android.
            explosion.BlendFunc = CCBlendFunc.NonPremultiplied;
#endif
            explosion.StopSystem();
            explosion.Visible = false;
            AddChild(explosion);
        }
コード例 #7
0
        public override void onEnter()
        {
            base.onEnter();

            Color = new ccColor3B(0, 0, 0);
            removeChild(m_background, true);
            m_background = null;

            CCParticleSystemQuad system = new CCParticleSystemQuad();

            system.initWithFile("Images/SpinningPeasPlist");
            system.setTextureWithRect(CCTextureCache.sharedTextureCache().addImage("Images/particles"), new CCRect(0, 0, 32, 32));
            addChild(system, 10);
            m_emitter = system;

            m_nIndex = 0;
            schedule(updateQuads, 2.0f);
        }
コード例 #8
0
        public override void onEnter()
        {
            base.onEnter();

            Color = new ccColor3B(0, 0, 0);
            removeChild(m_background, true);
            m_background = null;

            m_emitter = new CCParticleSystemQuad();
            // string filename = "Images/" + m_title + ".plist";
            string filename = "Images/" + m_title;

            m_emitter.initWithFile(filename);
            addChild(m_emitter, 10);

            m_emitter.IsBlendAdditive = true;

            setEmitterPosition();
        }
コード例 #9
0
        private void UpdatePowerPlay()
        {
            var powerPlay = (_numConsecutiveGems >= 5);

            if (powerPlay == _isPowerPlay)
            {
                return;
            }

            if (powerPlay)
            {
                // Start power-play
                _powerPlayParticles = new CCParticleSystemQuad("Particles/power-play.plist");
                _powerPlayParticles.AutoRemoveOnFinish = (true);
                _powerPlayParticles.SourcePosition     = new CCPoint(CCDirector.SharedDirector.WinSize.Width / 2, CCDirector.SharedDirector.WinSize.Height / 2);
                _powerPlayParticles.PosVar             = new CCPoint(CCDirector.SharedDirector.WinSize.Width / 2, CCDirector.SharedDirector.WinSize.Height / 2);
                _particleLayer.AddChild(_powerPlayParticles);


                var contentSize = CCDirector.SharedDirector.WinSize;
                _powerPlayLayer = new CCLayerColor(new CCColor4B(85, 0, 70, 0), contentSize.Width, contentSize.Height);

                var action = new CCSequence(new CCFadeIn(0.25f), new CCFadeOut(0.25f));
                _powerPlayLayer.RunAction(new CCRepeatForever(action));
                _powerPlayLayer.BlendFunc = CCBlendFunc.Additive;

                _effectsLayer.AddChild(_powerPlayLayer);
            }
            else
            {
                // Stop power-play
                if (_powerPlayParticles != null)
                {
                    _powerPlayParticles.StopSystem();

                    _powerPlayLayer.StopAllActions();
                    _powerPlayLayer.RunAction(new CCSequence(new CCFadeOut(0.5f), new CCRemoveSelf(true)));
                }
            }

            _isPowerPlay = powerPlay;
        }
コード例 #10
0
ファイル: GameLayer.cs プロジェクト: winiffercotes/Spacegame
        void CheckEnemyCollisions()
        {
            if (enemies.ChildrenCount > 0 && shots.ChildrenCount > 0)
            {
                foreach (var enemy in enemies.Children)
                {
                    foreach (var shot in shots.Children)
                    {
                        var d = CCPoint.Distance(shot.Position, enemy.Position);
                        if (d <= ENEMY_RADIUS + SHOT_RADIUS)
                        {
                            var pt = enemy.Position;
                            enemy.RemoveFromParent(true);
                            CCSimpleAudioEngine.SharedEngine.PlayEffect("sounds/explosion");

                            var explosion = new CCParticleSystemQuad("implode.plist");
                            explosion.Position = pt;
                            AddChild(explosion);
                        }
                    }
                }
            }
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        private bool RemoveConnectedGems(int x, int y)
        {
            // Check for bounds
            if (x < 0 || x >= Constants.KBoardWidth)
            {
                return(false);
            }
            if (y < 0 || y >= Constants.KBoardHeight)
            {
                return(false);
            }

            var connected   = FindConnectedGems(x, y);
            var removedGems = false;

            if (connected.Count >= 3)
            {
                _boardChangedSinceEvaluation = true;
                removedGems = true;

                AddScore(100 * connected.Count);

                var idxPup = -1;
                int pupX   = 0;
                int pupY   = 0;
                if (connected.Count >= 6)
                {
                    // Add power-up
                    idxPup = connected[(int)Math.Floor(CCRandom.NextDouble() * connected.Count)];
                    pupX   = idxPup % Constants.KBoardWidth;
                    pupY   = (int)Math.Floor((double)idxPup / Constants.KBoardWidth);
                }

                for (var i = 0; i < connected.Count; i++)
                {
                    var idx  = connected[i];
                    var gemX = idx % Constants.KBoardWidth;
                    var gemY = (int)Math.Floor((double)idx / Constants.KBoardWidth);

                    _board[idx] = -Constants.KNumRemovalFrames;
                    _gameBoardLayer.RemoveChild(_boardSprites[idx], true);
                    _boardSprites[idx] = null;

                    // Add particle effect
                    var particle = new CCParticleSystemQuad("Particles/taken-gem.plist");
                    particle.Position           = new CCPoint(_fieldPositionZero.X + gemX * Constants.KGemSize + Constants.KGemSize / 2, _fieldPositionZero.Y + gemY * Constants.KGemSize + Constants.KGemSize / 2);
                    particle.AutoRemoveOnFinish = (true);
                    _particleLayer.AddChild(particle);

                    // Add power-up
                    if (idx == idxPup)
                    {
                        _board[idx] = Constants.KBoardTypePup0;

                        var sprt = new CCSprite("crystalscrystals/bomb.png");
                        sprt.Position    = new CCPoint(_fieldPositionZero.X + gemX * Constants.KGemSize, _fieldPositionZero.Y + gemY * Constants.KGemSize);
                        sprt.AnchorPoint = CCPoint.Zero;
                        sprt.Opacity     = (0);
                        sprt.RunAction(new CCFadeIn(0.4f));

                        var sprtGlow = new CCSprite("crystalscrystals/bomb-hi.png");
                        sprtGlow.AnchorPoint = CCPoint.Zero;
                        sprtGlow.Opacity     = (0);
                        sprtGlow.RunAction(new CCRepeatForever(new CCSequence(new CCFadeIn(0.4f), new CCFadeOut(0.4f))));
                        sprt.AddChild(sprtGlow);

                        _boardSprites[idx] = sprt;
                        _gameBoardLayer.AddChild(sprt);
                    }
                    else if (idxPup != -1)
                    {
                        // Animate effect for power-up
                        var sprtLight = new CCSprite("crystalscrystals/bomb-light.png");
                        sprtLight.Position  = new CCPoint(_fieldPositionZero.X + gemX * Constants.KGemSize + Constants.KGemSize / 2, _fieldPositionZero.Y + gemY * Constants.KGemSize + Constants.KGemSize / 2);
                        sprtLight.BlendFunc = CCBlendFunc.Additive;
                        _effectsLayer.AddChild(sprtLight);

                        var movAction = new CCMoveTo(0.2f, new CCPoint(_fieldPositionZero.X + pupX * Constants.KGemSize + Constants.KGemSize / 2, _fieldPositionZero.Y + pupY * Constants.KGemSize + Constants.KGemSize / 2));
                        var seqAction = new CCSequence(movAction, new CCRemoveSelf());

                        sprtLight.RunAction(seqAction);
                    }
                }
            }
            else
            {
                CCSimpleAudioEngine.SharedEngine.PlayEffect("Sounds/miss.wav");
            }

            _lastMoveTime = DateTime.Now;

            return(removedGems);
        }
コード例 #13
0
        private bool ActivatePowerUp(int x, int y)
        {
            // Check for bounds
            if (x < 0 || x >= Constants.KBoardWidth)
            {
                return(false);
            }
            if (y < 0 || y >= Constants.KBoardHeight)
            {
                return(false);
            }

            var removedGems = false;

            var idx = x + y * Constants.KBoardWidth;

            if (_board[idx] == Constants.KBoardTypePup0)
            {
                // Activate bomb
                CCSimpleAudioEngine.SharedEngine.PlayEffect("Sounds/powerup.wav");

                removedGems = true;

                AddScore(2000);

                _board[idx] = -Constants.KNumRemovalFrames;
                _gameBoardLayer.RemoveChild(_boardSprites[idx], true);
                _boardSprites[idx] = null;

                // Remove a horizontal line
                int idxRemove;
                for (var xRemove = 0; xRemove < Constants.KBoardWidth; xRemove++)
                {
                    idxRemove = xRemove + y * Constants.KBoardWidth;
                    if (_board[idxRemove] >= 0 && _board[idxRemove] < 5)
                    {
                        _board[idxRemove] = -Constants.KNumRemovalFrames;
                        _gameBoardLayer.RemoveChild(_boardSprites[idxRemove], true);
                        _boardSprites[idxRemove] = null;
                    }
                }

                // Remove a vertical line
                for (var yRemove = 0; yRemove < Constants.KBoardHeight; yRemove++)
                {
                    idxRemove = x + yRemove * Constants.KBoardWidth;
                    if (_board[idxRemove] >= 0 && _board[idxRemove] < 5)
                    {
                        _board[idxRemove] = -Constants.KNumRemovalFrames;
                        _gameBoardLayer.RemoveChild(_boardSprites[idxRemove], true);
                        _boardSprites[idxRemove] = null;
                    }
                }

                // Add particle effects
                var hp = new CCParticleSystemQuad("Particles/taken-hrow.plist");
                hp.Position           = new CCPoint(_fieldPositionZero.X + Constants.KBoardWidth / 2 * Constants.KGemSize + Constants.KGemSize / 2, _fieldPositionZero.Y + y * Constants.KGemSize + Constants.KGemSize / 2);
                hp.AutoRemoveOnFinish = (true);
                _particleLayer.AddChild(hp);

                var vp = new CCParticleSystemQuad("Particles/taken-vrow.plist");
                vp.Position           = new CCPoint(_fieldPositionZero.X + x * Constants.KGemSize + Constants.KGemSize / 2, _fieldPositionZero.Y + Constants.KBoardHeight / 2 * Constants.KGemSize + Constants.KGemSize / 2);
                vp.AutoRemoveOnFinish = (true);
                _particleLayer.AddChild(vp);

                // Add explo anim
                var center = new CCPoint(_fieldPositionZero.X + x * Constants.KGemSize + Constants.KGemSize / 2, _fieldPositionZero.Y + y * Constants.KGemSize + Constants.KGemSize / 2);

                // Horizontal
                var sprtH0 = new CCSprite("crystalscrystals/bomb-explo.png");
                sprtH0.BlendFunc = new CCBlendFunc(CCOGLES.GL_SRC_ALPHA, CCOGLES.GL_ONE);
                sprtH0.Position  = (center);
                sprtH0.ScaleX    = (5);
                sprtH0.RunAction(new CCScaleTo(0.5f, 30, 1));
                sprtH0.RunAction(new CCSequence(new CCFadeOut(0.5f), new CCRemoveSelf(true)));
                _effectsLayer.AddChild(sprtH0);

                // Vertical
                var sprtV0 = new CCSprite("crystalscrystals/bomb-explo.png");
                sprtV0.BlendFunc = new CCBlendFunc(CCOGLES.GL_SRC_ALPHA, CCOGLES.GL_ONE);
                sprtV0.Position  = (center);
                sprtV0.ScaleY    = (5);
                sprtV0.RunAction(new CCScaleTo(0.5f, 1, 30));
                sprtV0.RunAction(new CCSequence(new CCFadeOut(0.5f), new CCRemoveSelf(true)));
                _effectsLayer.AddChild(sprtV0);

                // Horizontal
                var sprtH1 = new CCSprite("crystalscrystals/bomb-explo-inner.png");
                sprtH1.BlendFunc = new CCBlendFunc(CCOGLES.GL_SRC_ALPHA, CCOGLES.GL_ONE);
                sprtH1.Position  = (center);
                sprtH1.ScaleX    = (0.5f);
                sprtH1.RunAction(new CCScaleTo(0.5f, 8, 1));
                sprtH1.RunAction(new CCSequence(new CCFadeOut(0.5f), new CCRemoveSelf(true)));
                _effectsLayer.AddChild(sprtH1);

                // Vertical
                var sprtV1 = new CCSprite("crystalscrystals/bomb-explo-inner.png");
                sprtV1.Rotation  = (90);
                sprtV1.BlendFunc = new CCBlendFunc(CCOGLES.GL_SRC_ALPHA, CCOGLES.GL_ONE);
                sprtV1.Position  = (center);
                sprtV1.ScaleY    = (0.5f);
                sprtV1.RunAction(new CCScaleTo(0.5f, 8, 1));
                sprtV1.RunAction(new CCSequence(new CCFadeOut(0.5f), new CCRemoveSelf(true)));
                _effectsLayer.AddChild(sprtV1);
            }

            return(removedGems);
        }
コード例 #14
0
        public void createParticleSystem()
        {
            /*
             * 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);

            var particleSystem = new CCParticleSystemQuad(quantityParticles);

            switch (subtestNumber)
            {
            case 1:
                CCTexture2D.DefaultAlphaPixelFormat = CCSurfaceFormat.Color;
                particleSystem.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire");
                break;

            case 2:
                CCTexture2D.DefaultAlphaPixelFormat = CCSurfaceFormat.Bgra4444;
                particleSystem.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire");
                break;

            case 3:
                CCTexture2D.DefaultAlphaPixelFormat = CCSurfaceFormat.Alpha8;
                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.DefaultAlphaPixelFormat = CCSurfaceFormat.Color;
                particleSystem.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire");
                break;

            case 5:
                CCTexture2D.DefaultAlphaPixelFormat = CCSurfaceFormat.Bgra4444;
                particleSystem.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire");
                break;

            case 6:
                CCTexture2D.DefaultAlphaPixelFormat = CCSurfaceFormat.Alpha8;
                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.DefaultAlphaPixelFormat = CCSurfaceFormat.Color;
        }
コード例 #15
0
        public override void onEnter()
        {
            base.onEnter();

            m_emitter = new CCParticleSystemQuad();
            m_emitter.initWithTotalParticles(300);
            //m_emitter.autorelease();

            m_background.addChild(m_emitter, 10);
            ////m_emitter.release();	// win32 : Remove this line
            m_emitter.Texture = CCTextureCache.sharedTextureCache().addImage(TestResource.s_stars2);

            // duration
            m_emitter.Duration = -1;

            // gravity
            m_emitter.setGravity(new CCPoint(0, 0));

            // angle
            m_emitter.Angle    = 90;
            m_emitter.AngleVar = 360;

            // speed of particles
            m_emitter.setSpeed(160);
            m_emitter.setSpeedVar(20);

            // radial
            m_emitter.setRadialAccel(-120);
            m_emitter.setRadialAccelVar(0);

            // tagential
            m_emitter.setTangentialAccel(30);
            m_emitter.setTangentialAccelVar(0);

            // emitter position
            m_emitter.position = new CCPoint(160, 240);
            m_emitter.PosVar   = new CCPoint(0, 0);

            // life of particles
            m_emitter.Life    = 3;
            m_emitter.LifeVar = 1;

            // spin of particles
            m_emitter.StartSpin    = 0;
            m_emitter.StartSpinVar = 0;
            m_emitter.EndSpin      = 0;
            m_emitter.EndSpinVar   = 2000;

            // color of particles
            ccColor4F startColor = new ccColor4F(0.5f, 0.5f, 0.5f, 1.0f);

            m_emitter.StartColor = startColor;

            ccColor4F startColorVar = new ccColor4F(0.5f, 0.5f, 0.5f, 1.0f);

            m_emitter.StartColorVar = startColorVar;

            ccColor4F endColor = new ccColor4F(0.1f, 0.1f, 0.1f, 0.2f);

            m_emitter.EndColor = endColor;

            ccColor4F endColorVar = new ccColor4F(0.1f, 0.1f, 0.1f, 0.2f);

            m_emitter.EndColorVar = endColorVar;

            // size, in pixels
            m_emitter.StartSize    = 30.0f;
            m_emitter.StartSizeVar = 00.0f;
            m_emitter.EndSize      = (float)eParticleShowingProperty.kParticleStartSizeEqualToEndSize;

            // emits per second
            m_emitter.EmissionRate = m_emitter.TotalParticles / m_emitter.Life;

            // additive
            m_emitter.IsBlendAdditive = false;

            setEmitterPosition();
        }
コード例 #16
0
        public override void onEnter()
        {
            base.onEnter();

            Color = new ccColor3B(0, 0, 0);
            removeChild(m_background, true);
            m_background = null;

            m_emitter = new CCParticleSystemQuad();
            m_emitter.initWithTotalParticles(100);
            addChild(m_emitter, 10);
            m_emitter.Texture = CCTextureCache.sharedTextureCache().addImage("Images/fire");

            // duration
            m_emitter.Duration = (float)eParticleShowingProperty.kCCParticleDurationInfinity;

            // radius mode
            m_emitter.EmitterMode = (int)eParticleMode.kCCParticleModeRadius;

            // radius mode: start and end radius in pixels
            m_emitter.setStartRadius(50);
            m_emitter.setStartRadiusVar(0);
            m_emitter.setEndRadius((float)eParticleShowingProperty.kCCParticleStartRadiusEqualToEndRadius);
            m_emitter.setEndRadiusVar(0);

            // radius mode: degrees per second
            m_emitter.setRotatePerSecond(0);
            m_emitter.setRotatePerSecondVar(0);


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

            // emitter position
            CCSize size = CCDirector.sharedDirector().getWinSize();

            m_emitter.position = new CCPoint(size.width / 2, size.height / 2);
            m_emitter.PosVar   = new CCPoint(0, 0);

            // life of particles
            m_emitter.Life    = 5;
            m_emitter.LifeVar = 0;

            // spin of particles
            m_emitter.StartSpin    = 0;
            m_emitter.StartSpinVar = 0;
            m_emitter.EndSpin      = 0;
            m_emitter.EndSpinVar   = 0;

            // color of particles
            ccColor4F startColor = new ccColor4F(0.5f, 0.5f, 0.5f, 1.0f);

            m_emitter.StartColor = startColor;

            ccColor4F startColorVar = new ccColor4F(0.5f, 0.5f, 0.5f, 1.0f);

            m_emitter.StartColorVar = startColorVar;

            ccColor4F endColor = new ccColor4F(0.1f, 0.1f, 0.1f, 0.2f);

            m_emitter.EndColor = endColor;

            ccColor4F endColorVar = new ccColor4F(0.1f, 0.1f, 0.1f, 0.2f);

            m_emitter.EndColorVar = endColorVar;

            // size, in pixels
            m_emitter.StartSize    = 16;
            m_emitter.StartSizeVar = 0;
            m_emitter.EndSize      = (float)eParticleShowingProperty.kCCParticleStartSizeEqualToEndSize;

            // emits per second
            m_emitter.EmissionRate = m_emitter.TotalParticles / m_emitter.Life;

            // additive
            m_emitter.IsBlendAdditive = false;

            CCRotateBy rot = CCRotateBy.actionWithDuration(16, 360);

            m_emitter.runAction(CCRepeatForever.actionWithAction(rot));
        }