Пример #1
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)new CCSequence(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);
        }
Пример #2
0
        public Test5()
        {
            CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1);
            sp2 = new CCSprite(TestResource.s_pPathSister2);

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

            CCRotateBy rot = new CCRotateBy (2, 360);
            var rot_back = rot.Reverse() as CCActionInterval;
            CCAction forever = new CCRepeatForever ((CCActionInterval)new CCSequence(rot, rot_back));
            forever2 = (CCAction) (forever.Copy());
            forever.Tag = (101);
            forever2.Tag = (102);

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

            RemoveChild(sp2, true);
            AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2);

            // Sprite 1 should run and run
            // Sprite 2 should stop

            sp1.RunAction(forever);
            sp2.RunAction(forever2);

            // Experiment with removing sp2 and re-adding it after cleanup to reproduce an error in child management
//            ScheduleOnce(Stage2OfTest, 2.0f);
            Schedule(addAndRemove, 2.0f);
        }
Пример #3
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;
        }
Пример #4
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 = new CCSequence(move, move_back);
            CCAction fe2 = new CCRepeatForever ((CCActionInterval) seq);
            back.RunAction(fe2);
        }
Пример #5
0
        public void addNewSpriteWithCoords(CCPoint p)
        {
            CCSpriteBatchNode BatchNode = (CCSpriteBatchNode)GetChildByTag((int)kTags.kTagSpriteBatchNode);

            int idx = (int)(CCRandom.NextDouble() * 1400 / 100);
            int x = (idx % 5) * 85;
            int y = (idx / 5) * 121;


            CCSprite sprite = new CCSprite(BatchNode.Texture, new CCRect(x, y, 85, 121));
            BatchNode.AddChild(sprite);

            sprite.Position = (new CCPoint(p.X, p.Y));

            CCActionInterval action = null;
            float random = (float)CCRandom.NextDouble();

            if (random < 0.20)
                action = new CCScaleBy(3, 2);
            else if (random < 0.40)
                action = new CCRotateBy (3, 360);
            else if (random < 0.60)
                action = new CCBlink (1, 3);
            else if (random < 0.8)
                action = new CCTintBy (2, 0, -255, -255);
            else
                action = new CCFadeOut  (2);

            CCActionInterval action_back = (CCActionInterval)action.Reverse();
            CCActionInterval seq = (CCActionInterval)(new CCSequence(action, action_back));

            sprite.RunAction(new CCRepeatForever (seq));
        }
Пример #6
0
        public void addNewSpriteWithCoords(CCPoint p)
        {
            int idx = (int)(CCMacros.CCRandomBetween0And1() * 1400.0f / 100.0f);
            int x = (idx % 5) * 85;
            int y = (idx / 5) * 121;

            CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(x, y, 85, 121));
            AddChild(sprite);

            sprite.Position = p;

            CCActionInterval action;
            float random = CCMacros.CCRandomBetween0And1();

            if (random < 0.20)
                action = new CCScaleBy(3, 2);
            else if (random < 0.40)
                action = new CCRotateBy (3, 360);
            else if (random < 0.60)
                action = new CCBlink (1, 3);
            else if (random < 0.8)
                action = new CCTintBy (2, 0, -255, -255);
            else
                action = new CCFadeOut  (2);
            object obj = action.Reverse();
            CCActionInterval action_back = (CCActionInterval)action.Reverse();
            CCActionInterval seq = (CCActionInterval)(new CCSequence(action, action_back));

            sprite.RunAction(new CCRepeatForever (seq));
        }
Пример #7
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(1);
            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);
            //CCActionInterval scale_back = scale.reverse();
            CCActionInterval   scale_back  = null;
            CCFiniteTimeAction scale_seq   = new CCSequence(scale, scale_back, null);
            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, null);
            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);
        }
Пример #8
0
        public SpriteHybrid()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            // parents
            CCNode parent1 = new CCNode ();
            CCSpriteBatchNode parent2 = new CCSpriteBatchNode("animations/grossini", 50);

            AddChild(parent1, 0, (int)kTags.kTagNode);
            AddChild(parent2, 0, (int)kTags.kTagSpriteBatchNode);


            // IMPORTANT:
            // The sprite frames will be cached AND RETAINED, and they won't be released unless you call
            //     CCSpriteFrameCache::sharedSpriteFrameCache()->removeUnusedSpriteFrames);
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/grossini.plist");


            // create 250 sprites
            // only show 80% of them
            for (int i = 0; i < 250; i++)
            {
                int spriteIdx = (int)(CCRandom.NextDouble() * 14);
                string str = "";
                string temp = "";
                if (spriteIdx+1<10)
                {
                    temp = "0" + (spriteIdx+1);
                }
                else
                {
                    temp = (spriteIdx+1).ToString();
                }
                str = string.Format("grossini_dance_{0}.png", temp);
                CCSpriteFrame frame = CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName(str);
                CCSprite sprite = new CCSprite(frame);
                parent1.AddChild(sprite, i, i);

                float x = -1000;
                float y = -1000;
                if (CCRandom.NextDouble() < 0.2f)
                {
                    x = (float)(CCRandom.NextDouble() * s.Width);
                    y = (float)(CCRandom.NextDouble() * s.Height);
                }
                sprite.Position = (new CCPoint(x, y));

                CCActionInterval action = new CCRotateBy (4, 360);
                sprite.RunAction(new CCRepeatForever (action));
            }

            m_usingSpriteBatchNode = false;

            Schedule(reparentSprite, 2);
        }
Пример #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);
        }
Пример #10
0
        public static void AddJiggle(CCNode targetSprite)
        {
            var swingTime = CCRandom.Next(10, 31) / 100f;

            var rotateLeftAction = new CCRotateBy(swingTime, 1);
            var rotateRightAction = new CCRotateBy(swingTime * 2, -2);
            var rotateBackAction = new CCRotateBy(swingTime, 1);

            var rotateSequence = new CCSequence(rotateLeftAction, rotateRightAction, rotateBackAction);
            var repeatAction = new CCRepeatForever(rotateSequence);

            targetSprite.RunAction(repeatAction);
        }
Пример #11
0
        private void performanceActions(CCSprite pSprite)
        {
            CCSize size = CCDirector.SharedDirector.WinSize;
            pSprite.Position = new CCPoint((CCRandom.Next() % (int) size.Width), (CCRandom.Next() % (int) size.Height));

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

            float growDuration = 0.5f + (CCRandom.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);
        }
Пример #12
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = CCDirector.SharedDirector.WinSize;

            // the root object just rotates around
            m_root = new CCSprite(s_pPathR1);
            AddChild(m_root, 1);
            m_root.Position = new CCPoint(s.Width / 2, s.Height / 2);

            // the target object is offset from root, and the streak is moved to follow it
            m_target = new CCSprite(s_pPathR1);
            m_root.AddChild(m_target);
            m_target.Position = new CCPoint(s.Width / 4, 0);

            // create the streak object and add it to the scene
            streak = CCMotionStreak.Create(2, 3, 32, CCTypes.CCGreen, s_streak);
            streak.FastMode = true;
            AddChild(streak);
            // schedule an update on each frame so we can syncronize the streak with the target
            Schedule(onUpdate);

            var a1 = new CCRotateBy (2, 360);

            var action1 = new CCRepeatForever (a1);
            var motion = new CCMoveBy (2, new CCPoint(100, 0));
            m_root.RunAction(new CCRepeatForever ((CCActionInterval)CCSequence.FromActions(motion, motion.Reverse())));
            m_root.RunAction(action1);

            var colorAction = new CCRepeatForever ((CCActionInterval)
                CCSequence.FromActions(
                    new CCTintTo (0.2f, 255, 0, 0),
                    new CCTintTo (0.2f, 0, 255, 0),
                    new CCTintTo (0.2f, 0, 0, 255),
                    new CCTintTo (0.2f, 0, 255, 255),
                    new CCTintTo (0.2f, 255, 255, 0),
                    new CCTintTo (0.2f, 255, 0, 255),
                    new CCTintTo (0.2f, 255, 255, 255)
                    )
                );

            streak.RunAction(colorAction);
        }
        public SpriteBatchNodeAnchorPoint()
        {
            // small capacity. Testing resizing.
            // Don't use capacity=1 in your real game. It is expensive to resize the capacity
            CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 1);
            AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);

            CCSize s = CCDirector.SharedDirector.WinSize;


            CCActionInterval rotate = new CCRotateBy (10, 360);
            CCAction action = new CCRepeatForever (rotate);
            for (int i = 0; i < 3; i++)
            {
                CCSprite sprite = new CCSprite(batch.Texture, new CCRect(85 * i, 121 * 1, 85, 121));
                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;

                CCAction copy = (CCAction)(action.Copy());
                sprite.RunAction(copy);
                batch.AddChild(sprite, i);
            }
        }
Пример #14
0
        public Sprite6()
        {
            // small capacity. Testing resizing
            // Don't use capacity=1 in your real game. It is expensive to resize the capacity
            CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 1);
            AddChild(batch, 0, kTagSpriteBatchNode);
            batch.IgnoreAnchorPointForPosition = true;

            CCSize s = CCDirector.SharedDirector.WinSize;

            batch.AnchorPoint = new CCPoint(0.5f, 0.5f);
            batch.ContentSize = (new CCSize(s.Width, s.Height));


            // SpriteBatchNode actions
            CCActionInterval rotate = new CCRotateBy (5, 360);
            CCAction action = new CCRepeatForever (rotate);

            // SpriteBatchNode actions
            CCActionInterval rotate_back = (CCActionInterval)rotate.Reverse();
            CCActionInterval rotate_seq = (CCActionInterval)(CCSequence.FromActions(rotate, rotate_back));
            CCAction rotate_forever = new CCRepeatForever (rotate_seq);

            CCActionInterval scale = new CCScaleBy(5, 1.5f);
            CCActionInterval scale_back = (CCActionInterval)scale.Reverse();
            CCActionInterval scale_seq = (CCActionInterval)(CCSequence.FromActions(scale, scale_back));
            CCAction scale_forever = new CCRepeatForever (scale_seq);

            float step = s.Width / 4;

            for (int i = 0; i < 3; i++)
            {
                CCSprite sprite = new CCSprite(batch.Texture, new CCRect(85 * i, 121 * 1, 85, 121));
                sprite.Position = (new CCPoint((i + 1) * step, s.Height / 2));

                sprite.RunAction((CCAction)(action.Copy()));
                batch.AddChild(sprite, i);
            }

            batch.RunAction(scale_forever);
            batch.RunAction(rotate_forever);
        }
Пример #15
0
        public override void OnEnter()
        {
            base.OnEnter();

            float x, y;

            CCSize size = CCDirector.SharedDirector.WinSize;
            x = size.Width;
            y = size.Height;

            CCSprite sprite = new CCSprite(s_pPathGrossini);
            CCSprite spriteSister1 = new CCSprite(s_pPathSister1);
            CCSprite spriteSister2 = new CCSprite(s_pPathSister2);

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

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

            CCAction rot = new CCRotateBy (16, -3600);

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

            sprite.RunAction(rot);

            CCActionInterval jump1 = new CCJumpBy (4, new CCPoint(-400, 0), 100, 4);
            CCActionInterval jump2 = (CCActionInterval)jump1.Reverse();

            CCActionInterval rot1 = new CCRotateBy (4, 360 * 2);
            CCActionInterval rot2 = (CCActionInterval)rot1.Reverse();

            spriteSister1.RunAction(new CCRepeat (new CCSequence(jump2, jump1), 5));
            spriteSister2.RunAction(new CCRepeat (new CCSequence((CCFiniteTimeAction)(jump1.Copy()), (CCFiniteTimeAction)(jump2.Copy())), 5));

            spriteSister1.RunAction(new CCRepeat (new CCSequence(rot1, rot2), 5));
            spriteSister2.RunAction(new CCRepeat (new CCSequence((CCFiniteTimeAction)(rot2.Copy()), (CCFiniteTimeAction)(rot1.Copy())), 5));
        }
Пример #16
0
        public SceneTestLayer1()
        {
            CCMenuItemFont item1 = new CCMenuItemFont("(1) Test pushScene", onPushScene);
            CCMenuItemFont item2 = new CCMenuItemFont("(1) Test pushScene w/transition", onPushSceneTran);
            CCMenuItemFont item3 = new CCMenuItemFont("(1) Quit", onQuit);
            _PopMenuItem = new CCMenuItemFont("(1) Test popScene w/transition", onPopSceneTran);

            _TheMenu = new CCMenu(item1, item2, item3, _PopMenuItem);
            _TheMenu.AlignItemsVertically();

            AddChild(_TheMenu);

            CCSize s = CCDirector.SharedDirector.WinSize;
            CCSprite sprite = new CCSprite(s_pPathGrossini);
            AddChild(sprite);
            sprite.Position = new CCPoint(s.Width - 40, s.Height / 2);
            CCActionInterval rotate = new CCRotateBy (2, 360);
            CCAction repeat = new CCRepeatForever (rotate);
            sprite.RunAction(repeat);
        }
Пример #17
0
        public MenuLayer3()
        {
            CCMenuItemFont.FontName = "arial";
            CCMenuItemFont.FontSize = 28;

            CCLabelBMFont label = new CCLabelBMFont("Enable AtlasItem", "fonts/bitmapFontTest3.fnt");
            CCMenuItemLabel item1 = new CCMenuItemLabel(label, this.menuCallback2);
            CCMenuItemFont item2 = new CCMenuItemFont("--- Go Back ---", this.menuCallback);

            CCSprite spriteNormal = new CCSprite(s_MenuItem, new CCRect(0, 23 * 2, 115, 23));
            CCSprite spriteSelected = new CCSprite(s_MenuItem, new CCRect(0, 23 * 1, 115, 23));
            CCSprite spriteDisabled = new CCSprite(s_MenuItem, new CCRect(0, 23 * 0, 115, 23));


            CCMenuItemSprite item3 = new CCMenuItemSprite(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback3);
            m_disabledItem = item3;
            m_disabledItem.Enabled = false;

            CCMenu menu = new CCMenu(item1, item2, item3);
            menu.Position = new CCPoint(0, 0);

            CCSize s = CCDirector.SharedDirector.WinSize;

            item1.Position = new CCPoint(s.Width / 2 - 150, s.Height / 2);
            item2.Position = new CCPoint(s.Width / 2 - 200, s.Height / 2);
            item3.Position = new CCPoint(s.Width / 2, s.Height / 2 - 100);
            CCJumpBy jump = new CCJumpBy (3, new CCPoint(400, 0), 50, 4);
            item2.RunAction(new CCRepeatForever (
                                        (CCActionInterval)(CCSequence.FromActions(jump, jump.Reverse()))
                                        )
                            );
            CCActionInterval spin1 = new CCRotateBy (3, 360);
            CCActionInterval spin2 = (CCActionInterval)(spin1.Copy());
            CCActionInterval spin3 = (CCActionInterval)(spin1.Copy());

            item1.RunAction(new CCRepeatForever (spin1));
            item2.RunAction(new CCRepeatForever (spin2));
            item3.RunAction(new CCRepeatForever (spin3));

            AddChild(menu);
        }
Пример #18
0
        public override void OnEnter()
        {
            base.OnEnter();

            float x, y;

            CCSize size = CCDirector.SharedDirector.WinSize;
            x = size.Width;
            y = size.Height;

            CCNode blue = new CCLayerColor(new CCColor4B(0, 0, 255, 255));
            CCNode red = new CCLayerColor(new CCColor4B(255, 0, 0, 255));
            CCNode green = new CCLayerColor(new CCColor4B(0, 255, 0, 255));
            CCNode white = new CCLayerColor(new CCColor4B(255, 255, 255, 255));

            blue.Scale = (0.5f);
            blue.Position = (new CCPoint(-x / 4, -y / 4));
            blue.AddChild(SpriteLayer.node());

            red.Scale = (0.5f);
            red.Position = (new CCPoint(x / 4, -y / 4));

            green.Scale = (0.5f);
            green.Position = (new CCPoint(-x / 4, y / 4));
            green.AddChild(TestLayer.node());

            white.Scale = (0.5f);
            white.Position = (new CCPoint(x / 4, y / 4));

            AddChild(blue, -1);
            AddChild(white);
            AddChild(green);
            AddChild(red);

            CCAction rot = new CCRotateBy (8, 720);

            blue.RunAction(rot);
            red.RunAction((CCAction)(rot.Copy()));
            green.RunAction((CCAction)(rot.Copy()));
            white.RunAction((CCAction)(rot.Copy()));
        }
Пример #19
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = CCDirector.SharedDirector.WinSize;

            CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1);
            CCSprite sp2 = new CCSprite(TestResource.s_pPathSister2);
            CCSprite sp3 = new CCSprite(TestResource.s_pPathSister1);
            CCSprite 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);

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

            CCAction action1 = new CCRepeatForever ((CCActionInterval)new CCSequence(a1, a2, a2.Reverse())
                );
            CCAction action2 = new CCRepeatForever ((CCActionInterval)
                (new CCSequence(
                    (CCActionInterval) (a1.Copy()),
                    (CCActionInterval) (a2.Copy()),
                    a2.Reverse()))
                );

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

            sp1.RunAction(action1);
            sp2.RunAction(action2);
        }
Пример #20
0
        public SpriteAnchorPoint()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;


            CCActionInterval rotate = new CCRotateBy (10, 360);
            CCAction action = new CCRepeatForever (rotate);

            for (int i = 0; i < 3; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * i, 121 * 1, 85, 121));
                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, 10);

                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;

                CCAction copy = (CCAction)(action.Copy());
                sprite.RunAction(copy);
                AddChild(sprite, i);
            }
        }
Пример #21
0
        public ConvertToNode()
        {
            TouchEnabled = true;
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCRotateBy rotate = new CCRotateBy (10, 360);
            CCRepeatForever action = new CCRepeatForever (rotate);
            for (int i = 0; i < 3; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini");
                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, 10, 100 + i);

                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 copy = (CCRepeatForever) action.Copy();
                sprite.RunAction(copy);
                AddChild(sprite, i);
            }
        }
Пример #22
0
        public void addNewSprite()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCPoint p = new CCPoint((float)(CCRandom.NextDouble() * s.Width), (float)(CCRandom.NextDouble() * s.Height));

            int idx = (int)(CCRandom.NextDouble() * 1400 / 100);
            int x = (idx % 5) * 85;
            int y = (idx / 5) * 121;


            CCNode node = GetChildByTag((int)kTags.kTagSpriteBatchNode);
            CCSprite sprite = new CCSprite(m_texture1, new CCRect(x, y, 85, 121));
            node.AddChild(sprite);

            sprite.Position = (new CCPoint(p.X, p.Y));

            CCActionInterval action;
            float random = (float)CCRandom.NextDouble();

            if (random < 0.20)
                action = new CCScaleBy(3, 2);
            else if (random < 0.40)
                action = new CCRotateBy (3, 360);
            else if (random < 0.60)
                action = new CCBlink (1, 3);
            else if (random < 0.8)
                action = new CCTintBy (2, 0, -255, -255);
            else
                action = new CCFadeOut  (2);

            CCActionInterval action_back = (CCActionInterval)action.Reverse();
            CCActionInterval seq = (CCActionInterval)(CCSequence.FromActions(action, action_back));

            sprite.RunAction(new CCRepeatForever (seq));
        }
Пример #23
0
        public SceneTestLayer2()
        {
            m_timeCounter = 0;

            CCMenuItemFont item1 = new CCMenuItemFont("(2) replaceScene", onReplaceScene);
            CCMenuItemFont item2 = new CCMenuItemFont("(2) replaceScene w/transition", onReplaceSceneTran);
            CCMenuItemFont item3 = new CCMenuItemFont("(2) Go Back", onGoBack);
            _PopMenuItem = new CCMenuItemFont("(2) Test popScene w/transition", onPopSceneTran);

            _TheMenu = new CCMenu(item1, item2, item3, _PopMenuItem);
            _TheMenu.AlignItemsVertically();

            AddChild(_TheMenu);

            CCSize s = CCDirector.SharedDirector.WinSize;
            CCSprite sprite = new CCSprite(s_pPathGrossini);
            AddChild(sprite);
            sprite.Position = new CCPoint(s.Width - 40, s.Height / 2);
            CCActionInterval rotate = new CCRotateBy (2, 360);
            CCAction repeat = new CCRepeatForever (rotate);
            sprite.RunAction(repeat);

            Schedule(testDealloc);
        }
Пример #24
0
        public TMXReadWriteTest()
        {
            m_gid = 0;

            CCTMXTiledMap map = CCTMXTiledMap.Create("TileMaps/orthogonal-test2");
            AddChild(map, 0, kTagTileMap);

            CCTMXLayer layer = map.LayerNamed("Layer 0");
            layer.Texture.SetAntiAliasTexParameters();

            map.Scale = (1);

            CCSprite tile0 = layer.TileAt(new CCPoint(1, 63));
            CCSprite tile1 = layer.TileAt(new CCPoint(2, 63));
            CCSprite tile2 = layer.TileAt(new CCPoint(3, 62)); //new CCPoint(1,62));
            CCSprite tile3 = layer.TileAt(new CCPoint(2, 62));
            tile0.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile1.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile2.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile3.AnchorPoint = (new CCPoint(0.5f, 0.5f));

            CCMoveBy move = new CCMoveBy (0.5f, new CCPoint(0, 160));
            CCRotateBy rotate = new CCRotateBy (2, 360);
            CCScaleBy scale = new CCScaleBy(2, 5);
            CCFadeOut opacity = new CCFadeOut  (2);
            CCFadeIn fadein = new CCFadeIn  (2);
            CCScaleTo scaleback = new CCScaleTo(1, 1);
            CCCallFuncN finish = new CCCallFuncN(removeSprite);
            CCSequence seq0 = new CCSequence(move, rotate, scale, opacity, fadein, scaleback, finish);
            var seq1 = (CCActionInterval) (seq0.Copy());
            var seq2 = (CCActionInterval) (seq0.Copy());
            var seq3 = (CCActionInterval) (seq0.Copy());

            tile0.RunAction(seq0);
            tile1.RunAction(seq1);
            tile2.RunAction(seq2);
            tile3.RunAction(seq3);


            m_gid = layer.TileGIDAt(new CCPoint(0, 63));
            ////----UXLOG("Tile GID at:(0,63) is: %d", m_gid);

            Schedule(updateCol, 2.0f);
            Schedule(repaintWithGID, 2.0f);
            Schedule(removeTiles, 1.0f);

            ////----UXLOG("++++atlas quantity: %d", layer.textureAtlas().getTotalQuads());
            ////----UXLOG("++++children: %d", layer.getChildren().count() );

            m_gid2 = 0;
        }
Пример #25
0
        public SpriteBatchNodeChildren()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            // parents
            CCSpriteBatchNode batch = new CCSpriteBatchNode("animations/grossini", 50);

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

            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/grossini.plist");

            CCSprite sprite1 = new CCSprite("grossini_dance_01.png");
            sprite1.Position = (new CCPoint(s.Width / 3, s.Height / 2));

            CCSprite sprite2 = new CCSprite("grossini_dance_02.png");
            sprite2.Position = (new CCPoint(50, 50));

            CCSprite sprite3 = new CCSprite("grossini_dance_03.png");
            sprite3.Position = (new CCPoint(-50, -50));

            batch.AddChild(sprite1);
            sprite1.AddChild(sprite2);
            sprite1.AddChild(sprite3);

            // BEGIN NEW CODE
            var animFrames = new List<CCSpriteFrame>();
            string str = "";
            for (int i = 1; i < 15; i++)
            {
                string temp = "";
                if (i<10)
                {
                    temp = "0" + i;
                }
                else
                {
                    temp = i.ToString();
                }
                str = string.Format("grossini_dance_{0}.png", temp);
                CCSpriteFrame frame = CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName(str);
                animFrames.Add(frame);
            }

            CCAnimation animation = new CCAnimation(animFrames, 0.2f);
            sprite1.RunAction(new CCRepeatForever (new CCAnimate (animation)));
            // END NEW CODE

            CCActionInterval action = new CCMoveBy (2, new CCPoint(200, 0));
            CCActionInterval action_back = (CCActionInterval)action.Reverse();
            CCActionInterval action_rot = new CCRotateBy (2, 360);
            CCActionInterval action_s = new CCScaleBy(2, 2);
            CCActionInterval action_s_back = (CCActionInterval)action_s.Reverse();

            CCActionInterval seq2 = (CCActionInterval)action_rot.Reverse();
            sprite2.RunAction(new CCRepeatForever (seq2));

            sprite1.RunAction((CCAction)(new CCRepeatForever (action_rot)));
            sprite1.RunAction((CCAction)(new CCRepeatForever ((CCActionInterval)(new CCSequence(action, action_back)))));
            sprite1.RunAction((CCAction)(new CCRepeatForever ((CCActionInterval)(new CCSequence(action_s, action_s_back)))));

        }
Пример #26
0
        public override void OnEnter()
        {
            base.OnEnter();

            var s = CCDirector.SharedDirector.WinSize;

            // rotate and jump
            var jump1 = new CCJumpBy (4, new CCPoint(-s.Width + 80, 0), 100, 4);
            var jump2 = jump1.Reverse();
            var rot1 = new CCRotateBy (4, 360 * 2);
            var rot2 = rot1.Reverse();

            var seq3_1 = new CCSequence(jump2, jump1);
            var seq3_2 = new CCSequence(rot1, rot2);
            var spawn = new CCSpawn(seq3_1, seq3_2);
            var action = new CCSpeed (new CCRepeatForever (spawn), 1.0f);
            action.Tag = EaseTest.kTagAction1;

            var action2 = (CCAction) (action.Copy());
            var action3 = (CCAction) (action.Copy());

            action2.Tag = EaseTest.kTagAction1;
            action3.Tag = EaseTest.kTagAction1;

            m_grossini.RunAction(action2);
            m_tamara.RunAction(action3);
            m_kathia.RunAction(action);

            Schedule(altertime, 1.0f);
        }
Пример #27
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 = new CCSequence(act1, act2, act3, act4, act5, act6, act7, act8, act9);
            spr.RunAction(actF);
        }
Пример #28
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 = CCParticleSystem.kCCParticleDurationInfinity;

            // radius mode
            m_emitter.EmitterMode = CCEmitterMode.Radius;

            // radius mode: start and end radius in pixels
            m_emitter.StartRadius = (50);
            m_emitter.StartRadiusVar = (0);
            m_emitter.EndRadius = (CCParticleSystem.kCCParticleStartRadiusEqualToEndRadius);
            m_emitter.EndRadiusVar = (0);

            // radius mode: degrees per second
            m_emitter.RotatePerSecond = (0);
            m_emitter.RotatePerSecondVar = (0);


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

            // emitter position
            CCSize size = CCDirector.SharedDirector.WinSize;
            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
            var startColor = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f);
            m_emitter.StartColor = startColor;

            var startColorVar = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f);
            m_emitter.StartColorVar = startColorVar;

            var endColor = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f);
            m_emitter.EndColor = endColor;

            var 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 = CCParticleSystem.kCCParticleStartSizeEqualToEndSize;

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

            // additive
            m_emitter.BlendAdditive = false;

            CCRotateBy rot = new CCRotateBy (16, 360);
            m_emitter.RunAction(new CCRepeatForever (rot));
        }
Пример #29
0
        public override void OnEnter()
        {
            base.OnEnter();

            centerSprites(3);

            var actionTo = new CCRotateTo (2, 45);
            var actionTo2 = new CCRotateTo (2, -45);
            var actionTo0 = new CCRotateTo (2, 0);
            m_tamara.RunAction(new CCSequence(actionTo, actionTo0));

            var actionBy = new CCRotateBy (2, 360);
            var actionByBack = actionBy.Reverse();
            m_grossini.RunAction(new CCSequence(actionBy, actionByBack));

            // m_kathia->runAction( CCSequence::actions(actionTo2, actionTo0->copy()->autorelease(), NULL));
            m_kathia.RunAction(new CCSequence(actionTo2, (CCActionInterval) actionTo0.Copy()));
        }
Пример #30
0
        public override void OnEnter()
        {
            base.OnEnter();

            m_tamara.RemoveFromParentAndCleanup(true);
            m_grossini.RemoveFromParentAndCleanup(true);
            m_kathia.RemoveFromParentAndCleanup(true);

            var s = CCDirector.SharedDirector.WinSize;

            CCSize boxSize = new CCSize(100.0f, 100.0f);

            CCLayerColor box = new CCLayerColor(new CCColor4B(255, 255, 0, 255));
            box.AnchorPoint = new CCPoint(0.5f, 0.5f);
            box.ContentSize = boxSize;
            box.IgnoreAnchorPointForPosition = false;
            box.Position = new CCPoint(s.Width / 2, s.Height - 100 - box.ContentSize.Height / 2);
            this.AddChild(box);
            CCLabelTTF label = new CCLabelTTF("Standard cocos2d Skew", "Marker Felt", 16);
            label.Position = new CCPoint(s.Width / 2, s.Height - 100 + label.ContentSize.Height);
            this.AddChild(label);
            CCSkewBy actionTo = new CCSkewBy(2, 360, 0);
            CCSkewBy actionToBack = new CCSkewBy(2, -360, 0);

            box.RunAction(new CCSequence(actionTo, actionToBack));

            box = new CCLayerColor(new CCColor4B(255, 255, 0, 255));
            box.AnchorPoint = new CCPoint(0.5f, 0.5f);
            box.ContentSize = boxSize;
            box.IgnoreAnchorPointForPosition = false;
            box.Position = new CCPoint(s.Width / 2, s.Height - 250 - box.ContentSize.Height / 2);
            this.AddChild(box);
            label = new CCLabelTTF("Rotational Skew", "Marker Felt", 16);
            label.Position = new CCPoint(s.Width / 2, s.Height - 250 + label.ContentSize.Height / 2);
            this.AddChild(label);
            CCRotateBy actionTo2 = new CCRotateBy(2, 360, 0);
            CCRotateBy actionToBack2 = new CCRotateBy(2, -360, 0);
            box.RunAction(new CCSequence(actionTo2, actionToBack2));
        }
Пример #31
0
        public override void OnEnter()
        {
            base.OnEnter();

            centerSprites(3);

            var actionTo = new CCRotateTo(2, 37.2f, -37.2f);
            var actionToBack = new CCRotateTo(2, 0, 0);
            var actionBy = new CCRotateBy(2, 0.0f, -90.0f);
            var actionBy2 = new CCRotateBy(2, 45.0f, 45.0f);
            var actionByBack = (CCRotateBy) actionBy.Reverse();

            m_tamara.RunAction(new CCSequence(actionTo, actionToBack));
            m_grossini.RunAction(new CCSequence(actionBy, actionByBack));

            m_kathia.RunAction(new CCSequence(actionBy2, actionBy2.Reverse()));

            m_tamara.RunAction(new CCSequence(actionTo, actionToBack));
            m_grossini.RunAction(new CCSequence(actionBy, actionByBack));

            m_kathia.RunAction(new CCSequence(actionBy2, actionBy2.Reverse()));
        }