private void performanceActions20(CCSprite pSprite)
        {
            CCSize size = Layer.VisibleBoundsWorldspace.Size;

            if (CCRandom.Float_0_1() < 0.2f)
            {
                pSprite.Position = new CCPoint((CCRandom.Next() % (int)size.Width), (CCRandom.Next() % (int)size.Height));
            }
            else
            {
                pSprite.Position = new CCPoint(-1000, -1000);
            }

            float      period            = 0.5f + (CCRandom.Next() % 1000) / 500.0f;
            CCRotateBy rot               = new CCRotateBy(period, 360.0f * CCRandom.Float_0_1());
            var        rot_back          = (CCFiniteTimeAction)rot.Reverse();
            CCAction   permanentRotation = new CCRepeatForever(new CCSequence(rot, rot_back));

            pSprite.RunAction(permanentRotation);

            float growDuration      = 0.5f + (CCRandom.Next() % 1000) / 500.0f;
            CCFiniteTimeAction grow = new CCScaleBy(growDuration, 0.5f, 0.5f);
            CCAction           permanentScaleLoop = new CCRepeatForever(new CCSequence(grow, grow.Reverse()));

            pSprite.RunAction(permanentScaleLoop);
        }
Example #2
0
        void ExplodeBalloon()
        {
            CCSequence explosionSequence;
            CCColor4B  explosionColor = new CCColor4B(byte.Parse(balloonColor.Split(',')[0]), byte.Parse(balloonColor.Split(',')[1]),
                                                      byte.Parse(balloonColor.Split(',')[2]), 255);

            explosionSequence = new CCSequence(new CCScaleTo(0.6f, 100),
                                               new CCCallFunc(() => Color = new CCColor3B(explosionColor)),
                                               new CCCallFunc(() => UpdateColor()),
                                               new CCCallFunc(() =>
            {
                AddBalloon();
                ResetStopwatch();

                explosionSprite.Visible = false;

                explosionSprite.RunAction(new CCScaleTo(0.1f, 1));
            }));

            explosionSprite.Color    = new CCColor3B(explosionColor);
            explosionSprite.Position = balloonSprite.Position;
            explosionSprite.Visible  = true;

            explosionSprite.UpdateColor();
            philipsHue.SetBulbColor(int.Parse(explosionColor.R.ToString()), int.Parse(explosionColor.G.ToString()),
                                    int.Parse(explosionColor.B.ToString()));
            StopBackgroundMusic();
            ControlSound(false, BALLOON_POP_SOUND_FILE, "Play", SOUND_EFFECT_VOLUME);
            RemoveBalloon();

            explosionSprite.RunAction(explosionSequence);
        }
Example #3
0
        private void resetHealth()
        {
            if (_fallingObjects.Count > 30)
            {
                return;
            }

            CCSprite health = (CCSprite)_healthPool[_healthPoolIndex];

            _healthPoolIndex++;
            if (_healthPoolIndex == _healthPool.Count)
            {
                _healthPoolIndex = 0;
            }

            int health_x        = CCRandom.GetRandomInt(0, 1000) % (int)(_screenSize.Width * 0.8f + _screenSize.Width * 0.1f);
            int health_target_x = CCRandom.GetRandomInt(0, 1000) % (int)(_screenSize.Width * 0.8f + _screenSize.Width * 0.1f);

            health.StopAllActions();
            health.Position = new CCPoint(health_x, _screenSize.Height + health.BoundingBox.Size.Height * 0.5f);

            //create action (swing, move to target, and call function when done)
            CCFiniteTimeAction sequence = new CCSequence(
                new CCMoveTo(_healthSpeed, new CCPoint(health_target_x, _screenSize.Height * 0.15f)),
                new CCCallFuncN(fallingObjectDone));

            health.Visible = true;
            health.RunAction(_swingHealth);
            health.RunAction(sequence);
            _fallingObjects.Add(health);
        }
Example #4
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize size = Layer.VisibleBoundsWorldspace.Size;

            // The .png image MUST be power of 2 in order to create a continue effect.
            // eg: 32x64, 512x128, 256x1024, 64x64, etc..
            var sprite = new CCSprite("Images/pattern1.png", new CCRect(0, 0, 4096, 4096));

            AddChild(sprite, -1, (int)enumTag.kTagSprite1);
            sprite.Position = new CCPoint(size.Width / 2, size.Height / 2);

            // Cocos2D-XNA no longer uses TexParameters.  Please use the XNA SamplerState
//            sprite.Texture.TexParameters = new CCTexParams() {  MagFilter = (uint)All.Linear,
//                                                                MinFilter = (uint)All.Linear,
//                                                                WrapS = (uint)All.Repeat,
//                                                                WrapT = (uint)All.Repeat
//                                                              };

            sprite.Texture.SamplerState = SamplerState.LinearWrap;

            var rotate = new CCRotateBy(4, 360);

            sprite.RunAction(rotate);
            var scale     = new CCScaleBy(2, 0.04f);
            var scaleBack = (CCScaleBy)scale.Reverse();
            var seq       = new CCSequence(scale, scaleBack);

            sprite.RunAction(seq);
        }
Example #5
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize size = CCDirector.SharedDirector.WinSize;

            // The .png image MUST be power of 2 in order to create a continue effect.
            // eg: 32x64, 512x128, 256x1024, 64x64, etc..
            var sprite = new CCSprite("Images/pattern1.png", new CCRect(0, 0, 4096, 4096));

            AddChild(sprite, -1, (int)enumTag.kTagSprite1);
            sprite.Position = new CCPoint(size.Width / 2, size.Height / 2);

#if OPENGL
            sprite.Texture.TexParameters = new CCTexParams()
            {
                MagFilter = (uint)All.Linear,
                MinFilter = (uint)All.Linear,
                WrapS     = (uint)All.Repeat,
                WrapT     = (uint)All.Repeat
            };
#else
            sprite.Texture.SamplerState = SamplerState.LinearWrap;
#endif
            var rotate = new CCRotateBy(4, 360);
            sprite.RunAction(rotate);
            var scale     = new CCScaleBy(2, 0.04f);
            var scaleBack = (CCScaleBy)scale.Reverse();
            var seq       = new CCSequence(scale, scaleBack);
            sprite.RunAction(seq);
        }
        private void performanceActions20(CCSprite pSprite)
        {
            CCSize size = CCDirector.SharedDirector.WinSize;

            if (Random.Float_0_1() < 0.2f)
            {
                pSprite.Position = new CCPoint((Random.Next() % (int)size.Width), (Random.Next() % (int)size.Height));
            }
            else
            {
                pSprite.Position = new CCPoint(-1000, -1000);
            }

            float      period            = 0.5f + (Random.Next() % 1000) / 500.0f;
            CCRotateBy rot               = new CCRotateBy(period, 360.0f * Random.Float_0_1());
            var        rot_back          = (CCActionInterval)rot.Reverse();
            CCAction   permanentRotation = new CCRepeatForever(CCSequence.FromActions(rot, rot_back));

            pSprite.RunAction(permanentRotation);

            float            growDuration       = 0.5f + (Random.Next() % 1000) / 500.0f;
            CCActionInterval grow               = new CCScaleBy(growDuration, 0.5f, 0.5f);
            CCAction         permanentScaleLoop = new CCRepeatForever(new CCSequence(grow, grow.Reverse()));

            pSprite.RunAction(permanentScaleLoop);
        }
Example #7
0
        public void ScaleBalloon(float touchForce, float maxTouchForce)
        {
            if (gamePaused == false)
            {
                if (touchForce >= 1)
                {
                    CCScaleTo scaleUpTo = new CCScaleTo(0.25f, 1 + float.Parse((touchForce / 3).ToString()));

                    this.touchForce = touchForce;

                    balloonSprite.RunActions(scaleUpTo,
                                             new CCCallFunc(() =>
                    {
                        if (touchForce >= Math.Floor(double.Parse(maxTouchForce.ToString())))
                        {
                            this.touchForce = -1;

                            ExplodeBalloon();
                        }
                    }));
                }
                else
                {
                    CCScaleTo scaleDownTo = new CCScaleTo(0.25f, 1);

                    balloonSprite.RunAction(scaleDownTo);
                }
            }
        }
Example #8
0
        public SpriteOffsetAnchorRotation()
        {
            CCSize             s     = CCDirector.SharedDirector.WinSize;
            CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache;

            cache.AddSpriteFramesWithFile("animations/grossini.plist");
            cache.AddSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray");

            for (int i = 0; i < 3; i++)
            {
                //
                // Animation using Sprite BatchNode
                //
                CCSprite sprite = new CCSprite("grossini_dance_01.png");
                sprite.Position = (new CCPoint(s.Width / 4 * (i + 1), s.Height / 2));

                CCSprite point = new CCSprite("Images/r1");
                point.Scale    = 0.25f;
                point.Position = (sprite.Position);
                AddChild(point, 1);

                switch (i)
                {
                case 0:
                    sprite.AnchorPoint = new CCPoint(0, 0);
                    break;

                case 1:
                    sprite.AnchorPoint = new CCPoint(0.5f, 0.5f);
                    break;

                case 2:
                    sprite.AnchorPoint = new CCPoint(1, 1);
                    break;
                }

                point.Position = sprite.Position;

                var    animFrames = new List <CCSpriteFrame>(14);
                string str        = "";
                for (int j = 0; j < 14; j++)
                {
                    str = string.Format("grossini_dance_{0:00}.png", j + 1);
                    CCSpriteFrame frame = cache.SpriteFrameByName(str);
                    animFrames.Add(frame);
                }

                CCAnimation animation = new CCAnimation(animFrames, 0.3f);
                sprite.RunAction(new CCRepeatForever(new CCAnimate(animation)));
                sprite.RunAction(new CCRepeatForever(new CCRotateBy(10, 360)));

                AddChild(sprite, 0);

                //animFrames.release();    // win32 : memory leak    2010-0415
            }
        }
Example #9
0
        public Atlas4()
        {
            m_time = 0;

            // Upper Label
            CCLabelBMFont label = new CCLabelBMFont("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt");

            AddChild(label);

            CCSize s = CCDirector.SharedDirector.WinSize;

            label.Position    = new CCPoint(s.Width / 2, s.Height / 2);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);


            CCSprite BChar = (CCSprite)label.GetChildByTag(0);
            CCSprite FChar = (CCSprite)label.GetChildByTag(7);
            CCSprite AChar = (CCSprite)label.GetChildByTag(12);


            CCActionInterval rotate    = new CCRotateBy(2, 360);
            CCAction         rot_4ever = new CCRepeatForever(rotate);

            CCActionInterval   scale       = new CCScaleBy(2, 1.5f);
            CCFiniteTimeAction scale_back  = scale.Reverse();
            CCFiniteTimeAction scale_seq   = new CCSequence(scale, scale_back);
            CCAction           scale_4ever = new CCRepeatForever((CCActionInterval)scale_seq);

            CCActionInterval jump       = new CCJumpBy(0.5f, new CCPoint(), 60, 1);
            CCAction         jump_4ever = new CCRepeatForever(jump);

            CCActionInterval   fade_out   = new CCFadeOut(1);
            CCActionInterval   fade_in    = new CCFadeIn(1);
            CCFiniteTimeAction seq        = new CCSequence(fade_out, fade_in);
            CCAction           fade_4ever = new CCRepeatForever((CCActionInterval)seq);

            BChar.RunAction(rot_4ever);
            BChar.RunAction(scale_4ever);
            FChar.RunAction(jump_4ever);
            AChar.RunAction(fade_4ever);


            // Bottom Label
            CCLabelBMFont label2 = new CCLabelBMFont("00.0", "fonts/bitmapFontTest.fnt");

            AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);
            label2.Position = new CCPoint(s.Width / 2.0f, 80);

            CCSprite lastChar = (CCSprite)label2.GetChildByTag(3);

            lastChar.RunAction((CCAction)(rot_4ever.Copy()));

            //schedule( schedule_selector(Atlas4::step), 0.1f);
            base.Schedule(step, 0.1f);
        }
Example #10
0
        void OnTouchesEnded(List <CCTouch> touches, CCEvent touchEvent)
        {
            var monstersToDelete = new List <CCNode>();

            var touch         = touches[0];
            var touchLocation = Layer.ScreenToWorldspace(touch.LocationOnScreen);

            foreach (var monster in _monstersOnScreen)
            {
                if (monster.BoundingBox.ContainsPoint(touchLocation))
                {
                    monstersToDelete.Add(monster);

                    var m          = _monsters[monster.Tag];
                    var splashPool = new CCSprite(m.SplashSprite);

                    if (m.KillMethod == 1)
                    {
                        splashPool.Position = monster.Position;
                        AddChild(splashPool);

                        var fade      = new CCFadeOut(3.0f);
                        var remove    = new CCCallFuncN(RemoveSprite);
                        var sequencia = new CCSequence(fade, remove);
                        CCSimpleAudioEngine.SharedEngine.EffectsVolume = 0.7f;
                        CCSimpleAudioEngine.SharedEngine.PlayEffect("Sounds/SplatEffect");
                        splashPool.RunAction(sequencia);
                    }
                    else if (m.KillMethod == 2)
                    {
                        CCSimpleAudioEngine.SharedEngine.EffectsVolume = 1.0f;
                        CCSimpleAudioEngine.SharedEngine.PlayEffect("Sounds/pew-pew-lei");

                        splashPool.Position = monster.Position;
                        AddChild(splashPool);

                        var fade            = new CCFadeOut(3.0f);
                        var particleEmitter = new CCCallFuncND(StartExplosion, monster);
                        var sequencia       = new CCSequence(particleEmitter, fade);
                        CCSimpleAudioEngine.SharedEngine.EffectsVolume = 0.7f;
                        CCSimpleAudioEngine.SharedEngine.PlayEffect("Sounds/SplatEffect");
                        splashPool.RunAction(sequencia);
                    }
                    break;
                }
            }

            foreach (var monster in monstersToDelete)
            {
                monster.StopAllActions();
                _monstersOnScreen.Remove(monster);
                RemoveChild(monster);
            }
        }
Example #11
0
        public override void OnEnter()
        {
            base.OnEnter(); CCSize windowSize = Layer.VisibleBoundsWorldspace.Size;

            sprite1.Position = (new CCPoint(windowSize.Width / 3, windowSize.Height / 2));
            sprite2.Position = (new CCPoint(50, 50));
            sprite3.Position = (new CCPoint(-50, -50));

            sprite1.RunAction(new CCRepeatForever(new CCAnimate(animation)));
            sprite2.RunAction(new CCRepeatForever(seq2));

            sprite1.RunAction((CCAction)(new CCRepeatForever(action_rot)));
            sprite1.RunAction((CCAction)(new CCRepeatForever((CCFiniteTimeAction)(new CCSequence(action, action_back)))));
            sprite1.RunAction((CCAction)(new CCRepeatForever((CCFiniteTimeAction)(new CCSequence(action_s, action_s_back)))));
        }
Example #12
0
        public Test6()
        {
            CCSprite sp1  = new CCSprite(TestResource.s_pPathSister1);
            CCSprite sp11 = new CCSprite(TestResource.s_pPathSister1);

            CCSprite sp2  = new CCSprite(TestResource.s_pPathSister2);
            CCSprite sp21 = new CCSprite(TestResource.s_pPathSister2);

            sp1.Position = (new CCPoint(100, 160));
            sp2.Position = (new CCPoint(380, 160));

            CCActionInterval rot = new CCRotateBy(2, 360);
            var      rot_back    = rot.Reverse() as CCActionInterval;
            CCAction forever1    = new CCRepeatForever((CCActionInterval)CCSequence.FromActions(rot, rot_back));
            var      forever11   = (CCAction)(forever1.Copy());

            var forever2  = (CCAction)(forever1.Copy());
            var forever21 = (CCAction)(forever1.Copy());

            AddChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1);
            sp1.AddChild(sp11);
            AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2);
            sp2.AddChild(sp21);

            sp1.RunAction(forever1);
            sp11.RunAction(forever11);
            sp2.RunAction(forever2);
            sp21.RunAction(forever21);

            Schedule(addAndRemove, 2.0f);
        }
Example #13
0
        public override void OnNodeLoaded(CCNode node, CCNodeLoader nodeLoader)
        {
            CCRotateBy      ccRotateBy      = new CCRotateBy(20.0f, 360);
            CCRepeatForever ccRepeatForever = new CCRepeatForever(ccRotateBy);

            mBurstSprite.RunAction(ccRepeatForever);
        }
Example #14
0
        void UpdateMonkeyMovements(float dt)
        {
            if (Math.Abs(AccelerometerValue) > 0.5f)
            {
                CCPoint pos = monkey.Position;
                pos += new CCPoint(MONKEY_SPEED * AccelerometerValue * dt, 0);

                if (pos.X > VisibleBoundsWorldspace.Size.Width)
                {
                    pos.X = VisibleBoundsWorldspace.Size.Width;
                }
                else if (pos.X < 0)
                {
                    pos.X = 0;
                }

                monkey.Position = pos;
            }
            else
            {
                AccelerometerValue = 0;
            }

            if (Math.Abs(AccelerometerValue) < 0.5f)
            {
                monkey.StopAllActions();
            }
            else
            {
                if (monkey.NumberOfRunningActions < 1)
                {
                    monkey.RunAction(walkRepeat);
                }
            }
        }
Example #15
0
        public NodeToWorld()
        {
            //
            // This code tests that nodeToParent works OK:
            //  - It tests different anchor Points
            //  - It tests different children anchor points

            CCSprite back = new CCSprite(TestResource.s_back3);

            AddChild(back, -10);
            back.AnchorPoint = (new CCPoint(0, 0));
            CCSize backSize = back.ContentSize;

            CCMenuItem item = new CCMenuItemImage(TestResource.s_PlayNormal, TestResource.s_PlaySelect);
            CCMenu     menu = new CCMenu(item);

            menu.AlignItemsVertically();
            menu.Position = (new CCPoint(backSize.Width / 2, backSize.Height / 2));
            back.AddChild(menu);

            CCActionInterval rot = new CCRotateBy(5, 360);
            CCAction         fe  = new CCRepeatForever(rot);

            item.RunAction(fe);

            CCActionInterval move  = new CCMoveBy(3, new CCPoint(200, 0));
            var move_back          = (CCActionInterval)move.Reverse();
            CCFiniteTimeAction seq = CCSequence.FromActions(move, move_back);
            CCAction           fe2 = new CCRepeatForever((CCActionInterval)seq);

            back.RunAction(fe2);
        }
Example #16
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            var sp1 = new CCSprite(TestResource.s_pPathSister1);
            var sp2 = new CCSprite(TestResource.s_pPathSister2);
            var sp3 = new CCSprite(TestResource.s_pPathSister1);
            var sp4 = new CCSprite(TestResource.s_pPathSister2);

            sp1.Position = (new CCPoint(100, s.Height / 2));
            sp2.Position = (new CCPoint(380, s.Height / 2));

            AddChild(sp1);
            AddChild(sp2);

            sp3.Scale = (0.25f);
            sp4.Scale = (0.25f);

            sp1.AddChild(sp3);
            sp2.AddChild(sp4);

            var a1 = new CCRotateBy(2, 360);
            var a2 = new CCScaleBy(2, 2);

            var action1 = new CCRepeatForever(a1, a2, a2.Reverse());

            sp2.AnchorPoint = (new CCPoint(0, 0));

            sp1.RunAction(action1);
            sp2.RunAction(action1);
        }
        public override void OnEnter()
        {
            base.OnEnter();

            float x, y;

            CCSize size = CCDirector.SharedDirector.WinSize;

            x = size.Width;
            y = size.Height;

            CCSprite bg = new CCSprite("Images/background3");

            AddChild(bg, 0, EffectAdvanceScene.kTagBackground);
            bg.Position = new CCPoint(x / 2, y / 2);

            grossini = new CCSprite("Images/grossinis_sister2");
            bg.AddChild(grossini, 1, EffectAdvanceScene.kTagSprite1);
            grossini.Position = new CCPoint(x / 3.0f, 200);
            CCActionInterval   sc      = new CCScaleBy(2, 5);
            CCFiniteTimeAction sc_back = sc.Reverse();

            grossini.RunAction(new CCRepeatForever((CCActionInterval)(CCSequence.FromActions(sc, sc_back))));

            tamara = new CCSprite("Images/grossinis_sister1");
            bg.AddChild(tamara, 1, EffectAdvanceScene.kTagSprite2);
            tamara.Position = new CCPoint(2 * x / 3.0f, 200);
            CCActionInterval   sc2      = new CCScaleBy(2, 5);
            CCFiniteTimeAction sc2_back = sc2.Reverse();

            tamara.RunAction(new CCRepeatForever((CCActionInterval)(CCSequence.FromActions(sc2, sc2_back))));

            CCLabelTTF label = new CCLabelTTF(title(), "arial", 28);

            label.Position = new CCPoint(x / 2, y - 80);
            AddChild(label);
            label.Tag = EffectAdvanceScene.kTagLabel;

            string strSubtitle = subtitle();

            if (strSubtitle != null)
            {
                CCLabelTTF l = new CCLabelTTF(strSubtitle, "arial", 16);
                AddChild(l, 101);
                l.Position = new CCPoint(size.Width / 2, size.Height - 80);
            }

            CCMenuItemImage item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback);

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

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

            AddChild(menu, 1);
        }
Example #18
0
        CCSprite AddLocalBanana()
        {
            var banana = new CCSprite("BananaLocal");

            banana.Tag = 0;
            double rnd     = new Random().NextDouble();
            double randomX = (rnd > 0)
                                ? rnd * CCDirector.SharedDirector.WinSize.Width - banana.ContentSize.Width / 2
                                : banana.ContentSize.Width / 2;

            banana.Position = new CCPoint((float)randomX, CCDirector.SharedDirector.WinSize.Height - banana.ContentSize.Height / 2);

            byte[] message = buildBananaMessage((float)randomX);
            sendWarpUpdate(message);

            AddChild(banana);

            var moveBanana = new CCMoveTo(5.0f, new CCPoint(banana.Position.X, 0));

            var moveBananaComplete = new CCCallFuncN((node) => {
                node.RemoveFromParentAndCleanup(true);
                localBananas.Remove(banana);
            });

            var moveBananaSequence = new CCSequence(moveBanana, moveBananaComplete);

            banana.RunAction(moveBananaSequence);

            return(banana);
        }
Example #19
0
        public StressTest2()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLayer sublayer = new CCLayer();

            CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1);

            sp1.Position = (new CCPoint(80, s.Height / 2));

            CCActionInterval move             = new CCMoveBy(3, new CCPoint(350, 0));
            CCActionInterval move_ease_inout3 = new CCEaseInOut((CCActionInterval)(move.Copy()), 2.0f);
            var move_ease_inout_back3         = (CCActionInterval)move_ease_inout3.Reverse();
            CCFiniteTimeAction seq3           = CCSequence.FromActions(move_ease_inout3, move_ease_inout_back3);

            sp1.RunAction(new CCRepeatForever((CCActionInterval)seq3));
            sublayer.AddChild(sp1, 1);

            CCParticleFire fire = new CCParticleFire();

            fire.Texture  = (CCTextureCache.SharedTextureCache.AddImage("Images/fire"));
            fire.Position = (new CCPoint(80, s.Height / 2 - 50));

            var copy_seq3 = (CCActionInterval)(seq3.Copy());

            fire.RunAction(new CCRepeatForever(copy_seq3));
            sublayer.AddChild(fire, 2);

            Schedule((shouldNotLeak), 6.0f);

            AddChild(sublayer, 0, CocosNodeTestStaticLibrary.kTagSprite1);
        }
Example #20
0
        public void renderScreenShot()
        {
            var size    = Layer.VisibleBoundsWorldspace.Size;
            var texture = new CCRenderTexture(size, size);

            CCAffineTransform worldTransform = AffineWorldTransform;

            texture.Sprite.AnchorPoint = new CCPoint(0, 0);
            texture.BeginWithClear(CCColor4B.Transparent);

            Visit(ref worldTransform);

            texture.End();

            CCSprite sprite = new CCSprite(texture.Sprite.Texture);

            //sprite.Position = new CCPoint(256, 256);
            sprite.Position = new CCPoint(size.Width / 2, size.Height / 2);
            sprite.Opacity  = 182;
            //sprite.IsFlipY = true;
            AddChild(sprite, 999999);
            sprite.Color = CCColor3B.Green;

            sprite.RunAction(
                new CCSequence(
                    new CCFadeTo(2, 0),
                    new CCHide()
                    )
                );
        }
Example #21
0
        public override void Setup()
        {
            const int depth = 9;

            CCNode parent = this;

            for (int i = 0; i < depth; i++)
            {
                int size = 225 - i * (225 / (depth * 2));

                CCClippingNode clipper = new CCClippingNode();
                clipper.ContentSize    = new CCSize(size, size);
                clipper.AnchorPoint    = new CCPoint(0.5f, 0.5f);
                clipper.Position       = new CCPoint(parent.ContentSize.Width / 2, parent.ContentSize.Height / 2);
                clipper.AlphaThreshold = 0.05f;
                clipper.RunAction(new CCRepeatForever(new CCRotateBy(i % 3 != 0 ? 1.33f : 1.66f, i % 2 != 0 ? 90 : -90)));
                parent.AddChild(clipper);

                CCNode stencil = new CCSprite(TestResource.s_pPathGrossini);
                stencil.Scale       = 2.5f - (i * (2.5f / depth));
                stencil.AnchorPoint = new CCPoint(0.5f, 0.5f);
                stencil.Position    = new CCPoint(clipper.ContentSize.Width / 2, clipper.ContentSize.Height / 2);
                stencil.Visible     = false;
                stencil.RunAction(new CCSequence(new CCDelayTime(i), new CCShow()));
                clipper.Stencil = stencil;

                clipper.AddChild(stencil);

                parent = clipper;
            }
        }
Example #22
0
        public ScoreLayer() : base(CCColor4B.Blue)
        {
            background             = new CCSprite("aboutBg.jpg");
            background.AnchorPoint = CCPoint.AnchorLowerLeft;
            background.Position    = CCPoint.Zero;
            AddChild(background);

            mniBack = new CCMenuItemImage(new CCSprite("btnBack.png"), new CCSprite("btnBack.png"), delegate(object obj)
            {
                GameView.Director.PushScene(HomeLayer.HomeScene(GameView));
            });
            mnuBack = new CCMenu(new CCMenuItem[] { mniBack });
            mnuBack.AlignItemsVertically();

            AddChild(mnuBack);

            var sprSheet = new CCSpriteSheet("coin.plist");

            sprCoin = new CCSprite(sprSheet.Frames[0]);
            var spinningAnimation       = new CCAnimation(sprSheet.Frames, 0.05f);
            var spinningRepeatAnimation = new CCRepeatForever(new CCAnimate(spinningAnimation));

            sprCoin.RunAction(spinningRepeatAnimation);

            AddChild(sprCoin);

            label = new CCLabel("High scores", "Fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont);
            AddChild(label);
        }
Example #23
0
        public Layer3()
            : base(new ccColor4B (0,0,255,255))
        {
            CGSize s = CCDirector.SharedDirector ().WinSize ();
            CCMenuItemFont item0 = new CCMenuItemFont("Touch to pushScene (self)", delegate {
                CCScene newScene = new CCScene();
                newScene.AddChild (new Layer3 ());
                CCDirector.SharedDirector ().PushScene (new CCTransitionFade (0.5f, newScene, new ccColor3B (0, 255, 255)));
            });

            CCMenuItemFont item1 = new CCMenuItemFont("Touch to popScene", delegate {
                CCDirector.SharedDirector ().PopScene ();
            });

            CCMenuItemFont item2 = new CCMenuItemFont("Touch to popToRootScene", delegate {
                CCDirector.SharedDirector ().PopToRootScene ();
            });

            CCMenu menu = new CCMenu(item0, item1, item2);
            this.AddChild (menu);
            menu.AlignItemsVertically ();

            CCSprite sprite = new CCSprite("grossini.png", true);
            this.AddChild (sprite);
            sprite.Position = new CCPoint(s.Width / 2, 40);
            var rotate = new CCRotateBy (2, 360);
            var repeat = new CCRepeatForever (rotate);
            sprite.RunAction (repeat);
        }
Example #24
0
        private void DisplayHint()
        {
            _isDisplayingHint = true;

            var idx = FindMove();
            var x   = idx % Constants.KBoardWidth;
            var y   = (int)Math.Floor((double)idx / Constants.KBoardWidth);

            var connected = FindConnectedGems(x, y);

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

                var actionFadeIn  = new CCFadeIn(0.5f);
                var actionFadeOut = new CCFadeOut(0.5f);
                var actionSeq     = new CCSequence(actionFadeIn, actionFadeOut);
                var action        = new CCRepeatForever(actionSeq);

                var hintSprite = new CCSprite("crystalscrystals/hint.png");
                hintSprite.Opacity     = 0;
                hintSprite.Position    = new CCPoint(_fieldPositionZero.X + x * Constants.KGemSize, _fieldPositionZero.Y + y * Constants.KGemSize);
                hintSprite.AnchorPoint = CCPoint.Zero;
                _hintLayer.AddChild(hintSprite);
                hintSprite.RunAction(action);
            }
        }
Example #25
0
        public TextLayer() : base()
        {
            Color   = new CCColor3B(32, 128, 32);
            Opacity = 255;

            BaseNode = new CCNodeGrid();
            var effect = CurrentAction;

            BaseNode.RunAction(effect);
            AddChild(BaseNode, 0, EffectTestScene.kTagBackground);

            var bg = new CCSprite(TestResource.s_back3);

            BaseNode.AddChild(bg, 0);

            var Kathia = new CCSprite(TestResource.s_pPathSister2);

            BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);

            var sc      = new CCScaleBy(2, 5);
            var sc_back = sc.Reverse();

            Kathia.RunAction(new CCRepeatForever(sc, sc_back));


            var Tamara = new CCSprite(TestResource.s_pPathSister1);

            BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);

            var sc2      = new CCScaleBy(2, 5);
            var sc2_back = sc2.Reverse();

            Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));
        }
Example #26
0
 public void Play(string name)
 {
     if (anims.ContainsKey(name))
     {
         sprite.RunAction(anims[name]);
     }
 }
Example #27
0
        public SpriteBatchNodeAliased()
        {
            CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 10);

            AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);

            CCSize s = CCDirector.SharedDirector.WinSize;

            CCSprite sprite1 = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121));

            sprite1.Position = (new CCPoint(s.Width / 2 - 100, s.Height / 2));
            batch.AddChild(sprite1, 0, (int)kTagSprite.kTagSprite1);

            CCSprite sprite2 = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121));

            sprite2.Position = (new CCPoint(s.Width / 2 + 100, s.Height / 2));
            batch.AddChild(sprite2, 0, (int)kTagSprite.kTagSprite2);

            CCActionInterval scale      = new CCScaleBy(2, 5);
            CCActionInterval scale_back = (CCActionInterval)scale.Reverse();
            CCActionInterval seq        = (CCActionInterval)(CCSequence.FromActions(scale, scale_back));
            CCAction         repeat     = new CCRepeatForever(seq);

            CCAction repeat2 = (CCAction)(repeat.Copy());

            sprite1.RunAction(repeat);
            sprite2.RunAction(repeat2);
        }
        protected override void InitialiseScenes()
        {
            base.InitialiseScenes();

            var    bounds       = Layer.VisibleBoundsWorldspace;
            CCRect viewportRect = Viewport.ViewportInPixels;

            CCRenderTexture outTexture   = new CCRenderTexture(bounds.Size, viewportRect.Size);
            CCSprite        outTexSprite = outTexture.Sprite;

            var worldTransform = Layer.AffineWorldTransform;

            outTexture.BeginWithClear(0, 0, 0, 0);
            OutSceneNodeContainer.Visit(ref worldTransform);
            outTexture.End();

            outTexSprite.AnchorPoint = CCPoint.AnchorMiddle;
            outTexSprite.Position    = new CCPoint(bounds.Origin.X + bounds.Size.Width / 2, bounds.Size.Height / 2);
            outTexSprite.BlendFunc   = CCBlendFunc.NonPremultiplied;
            outTexSprite.Opacity     = 255;

            CCAction layerAction = new CCSequence(new CCFadeTo(Duration, 0), new CCCallFunc((Finish)));

            outTexSprite.RunAction(layerAction);

            Layer.AddChild(outTexture.Sprite, 3);

            InSceneNodeContainer.Visible  = true;
            OutSceneNodeContainer.Visible = false;
        }
Example #29
0
        public override void OnEnter()
        {
            base.OnEnter();

            float x, y;

            CCSize size = Layer.VisibleBoundsWorldspace.Size;

            x = size.Width;
            y = size.Height;

            CCSprite sprite        = new CCSprite(grossini);
            CCSprite spriteSister1 = new CCSprite(sister1);
            CCSprite spriteSister2 = new CCSprite(sister2);

            sprite.Scale        = 1.5f;
            spriteSister1.Scale = 1.5f;
            spriteSister2.Scale = 1.5f;

            sprite.Position        = size.Center;
            spriteSister1.Position = (new CCPoint(40, y / 2));
            spriteSister2.Position = (new CCPoint(x - 40, y / 2));

            AddChild(sprite);
            AddChild(spriteSister1);
            AddChild(spriteSister2);

            sprite.RunAction(rot);

            spriteSister1.Repeat(5, jump2, jump1);
            spriteSister2.Repeat(5, jump1, jump2);

            spriteSister1.Repeat(5, rot1, rot2);
            spriteSister2.Repeat(5, rot2, rot1);
        }
Example #30
0
        public override void OnEnter()
        {
            base.OnEnter();

            centerSprites(0);

            var spr = new CCSprite("Images/grossini");

            spr.Position = new CCPoint(100, 100);
            AddChild(spr);

            var act1 = new CCCallFuncN(logSprRotation);
            var act2 = new CCRotateBy(0.25f, 45);
            var act3 = new CCCallFuncN(logSprRotation);
            var act4 = new CCRotateBy(0.25f, 45);
            var act5 = new CCCallFuncN(logSprRotation);
            var act6 = new CCRotateBy(0.25f, 45);
            var act7 = new CCCallFuncN(logSprRotation);
            var act8 = new CCRotateBy(0.25f, 45);
            var act9 = new CCCallFuncN(logSprRotation);

            var actF = CCSequence.FromActions(act1, act2, act3, act4, act5, act6, act7, act8, act9);

            spr.RunAction(actF);
        }
Example #31
0
        public override bool Init()
        {
            InitWithColor(new CCColor4B(0, 0, 255, 255));

            var item0 = new CCMenuItemFont("(3) Touch to pushScene (self)", item0Clicked);
            var item1 = new CCMenuItemFont("(3) Touch to popScene", item1Clicked);
            var item2 = new CCMenuItemFont("(3) Touch to popToRootScene", item2Clicked);
            var item3 = new CCMenuItemFont("(3) Touch to popToSceneStackLevel(2)", item3Clicked);

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

            menu.AlignItemsVertically();

            AddChild(menu);

            CCSize   s      = CCDirector.SharedDirector.WinSize;
            CCSprite sprite = new CCSprite(s_pPathGrossini);

            AddChild(sprite);

            sprite.Position = new CCPoint(s.Width / 2, 40);
            CCActionInterval rotate = new CCRotateBy(2, 360);
            CCAction         repeat = new CCRepeatForever(rotate);

            sprite.RunAction(repeat);

            Schedule(testDealloc);

            return(true);
        }
Example #32
0
        public void TankFire(float t)
        {
            Console.WriteLine("Shoot");
            CCSprite bullet = new CCSprite(CCApplication.SharedApplication.SpriteFrameCache["Image 904 at frame 10.png"]);
            CCLayer layer = (CCLayer)GetChildByTag(2); //[self.parent.parent getChildByTag:2];

            CCPoint hp = Position;
            CCPoint sp = Parent.Position;
            CCPoint position = new CCPoint(hp.X + sp.X - 80, hp.Y + sp.Y + 25);

            bullet.Position = position;
            layer.AddChild(bullet, 2);
            bullet.Tag = 851137;
            bullet.RunAction(new CCMoveBy(1.5f, new CCPoint(-400, 0)));
        }
Example #33
0
        public Layer1()
            : base(new ccColor4B (0, 255, 0, 255))
        {
            CCMenuItemFont item1 = new CCMenuItemFont("Test pushScene", OnPushScene);
            CCMenuItemFont item2 = new CCMenuItemFont("Test pushScene w/transition", OnPushSceneTran);
            CCMenuItemFont item3 = new CCMenuItemFont("Quit", OnQuit);

            CCMenu menu = new CCMenu(item1, item2, item3);
            menu.AlignItemsVertically ();
            this.AddChild (menu);

            CGSize s = CCDirector.SharedDirector ().WinSize ();
            CCSprite sprite = new CCSprite("grossini.png", true);
            this.AddChild (sprite);
            sprite.Position = new CCPoint(s.Width-40, s.Height/2);
            var rotate = new CCRotateBy (2, 360);
            var repeat = new CCRepeatForever (rotate);
            sprite.RunAction (repeat);

            this.Schedule (new MonoMac.ObjCRuntime.Selector ("testDealloc:"));
        }
Example #34
0
        public TextLayer()
            : base()
        {
            SizeF s = CCDirector.SharedDirector ().WinSize ();
            float x = s.Width;
            float y = s.Height;

            CCNode node = new CCNode ();
            CCAction effectClass = RestartAction (3f);
            node.RunAction (effectClass);
            this.AddChild (node, 0, (int)EffectLayers.kTagBackground);

            CCSprite bg = new CCSprite ("background3.png", true);
            node.AddChild (bg, 0);
            bg.Position = new PointF(x/2, y/2);

            CCSprite grossini = new CCSprite ("grossinis_sister2.png", true);
            node.AddChild (grossini, 1);
            grossini.Position = new PointF(x/3, y/2);
            CCScaleBy sc = new CCScaleBy (2, 5);
            CCActionInterval sc_back = sc.Reverse ();
            grossini.RunAction (new CCRepeatForever (new CCSequence (sc, sc_back)));

            CCSprite tamara = new CCSprite ("grossinis_sister1.png", true);
            node.AddChild (tamara, 1, (int)EffectLayers.kTagSprite2);
            tamara.Position = new PointF (2*x/3, y/2);
            CCScaleBy sc2 = new CCScaleBy (2, 5);
            CCActionInterval sc2_back = sc2.Reverse ();
            tamara.RunAction (new CCRepeatForever (new CCSequence (sc2, sc2_back)));

            CCLabelTTF label = new CCLabelTTF (effectsList[actionIdx].Replace("Demo", ""), "Marker Felt", 32);
            label.Position = new PointF (x/2, y-80);
            this.AddChild (label);
            label.Tag = (int)EffectLayers.kTagLabel;

            //menu
            CCMenuItemImage item1 = new CCMenuItemImage ("b1.png", "b2.png", null, BackCallback);
            CCMenuItemImage item2 = new CCMenuItemImage ("r1.png", "r2.png", null, RestartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage ("f1.png", "f2.png", null, NextCallback);

            CCMenu menu = new CCMenu (item1, item2, item3);
            menu.Position = PointF.Empty;
            item1.Position = new PointF(s.Width/2 - item2.ContentSize.Width*2, item2.ContentSize.Height/2);
            item2.Position = new PointF( s.Width/2, item2.ContentSize.Height/2);
            item3.Position = new PointF( s.Width/2 + item2.ContentSize.Width*2, item2.ContentSize.Height/2);
            this.AddChild (menu, 1);

            this.Schedule (new MonoMac.ObjCRuntime.Selector ("checkAnim:"));
        }