Esempio n. 1
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));

			var rot = new CCRotateBy (2, 360);
            var rot_back = rot.Reverse();

			var forever = new CCRepeatForever (rot, rot_back) { Tag = 101 };

			// Since Actions are immutable to set the tag differently we need to 
			// create a new action.  Notice that the same actions can be used in
			// this case instead of copying them as well.
			forever2 = new CCRepeatForever (rot, rot_back) { 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);
        }
Esempio n. 2
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));

            CCFiniteTimeAction rot = new CCRotateBy (2, 360);
            var rot_back = rot.Reverse();
			var forever1 = new CCRepeatForever (rot, rot_back);

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

            sp1.RunAction(forever1);
            sp11.RunAction(forever1);
			sp2.RunAction(forever1);
            sp21.RunAction(forever1);

            Schedule(addAndRemove, 2.0f);
        }
        public SpriteBatchNodeChildrenChildren()
        {
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/ghosts.plist");

            var rot = new CCRotateBy (10, 360);
            seq = new CCRepeatForever (rot);

            var rot_back = rot.Reverse();
            rot_back_fe = new CCRepeatForever (rot_back);

            // SpriteBatchNode: 3 levels of children

            aParent = new CCSpriteBatchNode("animations/ghosts");
            AddChild(aParent);

            // parent
            l1 = new CCSprite("father.gif");
            aParent.AddChild(l1);


            // child left
            l2a = new CCSprite("sister1.gif");

            l1.AddChild(l2a);

            // child right
            l2b = new CCSprite("sister2.gif");

            l1.AddChild(l2b);


            // child left bottom
            l3a1 = new CCSprite("child1.gif");
            l3a1.Scale = 0.45f;
            l2a.AddChild(l3a1);

            // child left top
            l3a2 = new CCSprite("child1.gif");
            l3a2.Scale = 0.45f;
            l2a.AddChild(l3a2);

            // child right bottom
            l3b1 = new CCSprite("child1.gif");
            l3b1.Scale = 0.45f;
            l3b1.FlipY = true;
            l2b.AddChild(l3b1);

            // child right top
            l3b2 = new CCSprite("child1.gif");
            l3b2.Scale = 0.45f;
            l3b2.FlipY = true;
            l2b.AddChild(l3b2);
        }
Esempio n. 4
0
        private void performanceActions(CCSprite pSprite)
        {
            CCSize size = Layer.VisibleBoundsWorldspace.Size;
            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 (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);
        }
Esempio n. 5
0
        public Sprite6()
        {
            // small capacity. Testing resizing
            // Don't use capacity=1 in your real game. It is expensive to resize the capacity
            batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 1);


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

            // SpriteBatchNode actions
            rotate_back = rotate.Reverse();

            scale = new CCScaleBy(5, 1.5f);
            scale_back = scale.Reverse();

            for (int i = 0; i < 3; i++)
            {
                CCSprite sprite = new CCSprite(batch.Texture, new CCRect(85 * i, 121 * 1, 85, 121));
                batch.AddChild(sprite, i);
            }
        }
Esempio n. 6
0
 public ActionRotate()
 {
     actionTo = new CCRotateTo (2, 45);
     actionTo2 = new CCRotateTo (2, -45);
     actionTo0 = new CCRotateTo (2, 0);
     actionBy = new CCRotateBy (2, 360);
     actionByBack = (CCRotateBy)actionBy.Reverse();
 }
Esempio n. 7
0
        public override void OnEnter()
        {
            base.OnEnter(); 

            CenterSprites(3);

            var actionTo = new CCRotateTo(2, 180, 180);
            var actionToBack = new CCRotateTo(2, 0, 0);
            var actionBy = new CCRotateBy(2, 0.0f, 360);
            var actionByBack = actionBy.Reverse();

            var actionBy2 = new CCRotateBy(2, 360, 0.0f);
            var actionBy2Back = actionBy2.Reverse ();

            Tamara.RunActions(actionBy, actionByBack);
            Grossini.RunActions(actionTo, actionToBack);
            Kathia.RunActions(actionBy2, actionBy2Back);
        }
Esempio n. 8
0
        public override void OnEnter()
        {
            base.OnEnter();

            var s = Layer.VisibleBoundsWorldspace.Size;

            // 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);

            speedAction1 = new CCSpeed(new CCRepeatForever (spawn), 1.0f);
            speedAction2 = new CCSpeed(new CCRepeatForever (spawn), 2.0f);
            speedAction3 = new CCSpeed(new CCRepeatForever (spawn), 0.5f);

            m_grossini.RunAction(speedAction1);
			m_tamara.RunAction(speedAction2);
			m_kathia.RunAction(speedAction3);
        }