示例#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);
        }
        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);
        }
示例#4
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);
        }
示例#5
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));
        }
示例#6
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);
        }
        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)))));

        }
示例#8
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()));
        }
示例#9
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()));
        }
        public SpriteChildrenChildren()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

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

            CCNode aParent;
            CCSprite l1, l2a, l2b, l3a1, l3a2, l3b1, l3b2;
            CCActionInterval rot = new CCRotateBy (10, 360);
            CCAction seq = new CCRepeatForever (rot);

            CCActionInterval rot_back = (CCActionInterval)rot.Reverse();
            CCAction rot_back_fe = new CCRepeatForever (rot_back);

            //
            // SpriteBatchNode: 3 levels of children
            //

            aParent = new CCNode ();
            AddChild(aParent);

            // parent
            l1 = new CCSprite("father.gif");
            l1.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            l1.RunAction((CCAction)(seq.Copy()));
            aParent.AddChild(l1);
            CCSize l1Size = l1.ContentSize;

            // child left
            l2a = new CCSprite("sister1.gif");
            l2a.Position = (new CCPoint(-50 + l1Size.Width / 2, 0 + l1Size.Height / 2));
            l2a.RunAction((CCAction)(rot_back_fe.Copy()));
            l1.AddChild(l2a);
            CCSize l2aSize = l2a.ContentSize;

            // child right
            l2b = new CCSprite("sister2.gif");
            l2b.Position = (new CCPoint(+50 + l1Size.Width / 2, 0 + l1Size.Height / 2));
            l2b.RunAction((CCAction)(rot_back_fe.Copy()));
            l1.AddChild(l2b);
            CCSize l2bSize = l2a.ContentSize;

            // child left bottom
            l3a1 = new CCSprite("child1.gif");
            l3a1.Scale = 0.45f;
            l3a1.Position = new CCPoint(0 + l2aSize.Width / 2, -100 + l2aSize.Height / 2);
            l2a.AddChild(l3a1);

            // child left top
            l3a2 = new CCSprite("child1.gif");
            l3a2.Scale = 0.45f;
            l3a1.Position = (new CCPoint(0 + l2aSize.Width / 2, +100 + l2aSize.Height / 2));
            l2a.AddChild(l3a2);

            // child right bottom
            l3b1 = new CCSprite("child1.gif");
            l3b1.Scale = 0.45f;
            l3b1.FlipY = true;
            l3b1.Position = (new CCPoint(0 + l2bSize.Width / 2, -100 + l2bSize.Height / 2));
            l2b.AddChild(l3b1);

            // child right top
            l3b2 = new CCSprite("child1.gif");
            l3b2.Scale = 0.45f;
            l3b2.FlipY = true;
            l3b1.Position = new CCPoint(0 + l2bSize.Width / 2, +100 + l2bSize.Height / 2);
            l2b.AddChild(l3b2);
        }