Пример #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);
        }
Пример #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);
        }
Пример #3
0
        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));
            sprite.Position = (new CCPoint(p.X, p.Y));
            BatchNode.AddChild(sprite);


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

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

            sprite.RunAction(new CCRepeatForever (seq));
        }
Пример #4
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();

            CCSize winSize = VisibleBoundsWorldspace.Size;
            float x = winSize.Center.X;
            float y = winSize.Center.Y;

            //var widgetSize = _widget->getContentSize();

            var moveTo = new CCMoveBy(1.0f, new CCPoint(30, 0));
            var moveBack = moveTo.Reverse();
            var rotateBy = new CCRotateBy(1.0f, 180);
            var scaleBy = new CCScaleTo(1.0f, -2.0f);
            var action = new CCSequence(moveTo, moveBack, rotateBy, scaleBy);


            var normalSprite1 = new CCSprite("Images/animationbuttonnormal.png");
            normalSprite1.Position = winSize.Center;
            normalSprite1.PositionX -= 100;
            normalSprite1.PositionY += 100;
            normalSprite1.FlipY = true;


            AddChild(normalSprite1);
            normalSprite1.RunAction(action);

            var normalSprite2 = new CCScale9Sprite("Images/animationbuttonnormal.png");
            normalSprite2.Position = winSize.Center;
            normalSprite2.PositionX -= 80;
            normalSprite2.PositionY += 100;
            normalSprite2.IsScale9Enabled = false;
            normalSprite2.Opacity = 100;
            AddChild(normalSprite2);
            normalSprite2.Color = CCColor3B.Green;
            normalSprite2.RunAction(action);

            
            var sp1 = new CCScale9Sprite("Images/animationbuttonnormal.png");
            sp1.Position = winSize.Center;
            sp1.PositionX -= 100;
            sp1.PositionY -= 50;
            sp1.Scale = 1.2f;
            sp1.ContentSize = new CCSize(100, 100);
            sp1.Color = CCColor3B.Green;
            AddChild(sp1);
            sp1.RunAction(action);

            var sp2 = new CCScale9Sprite("Images/animationbuttonnormal.png");
            sp2.Position = winSize.Center;
            sp2.PositionX += 100;
            sp2.PositionY -= 50;
            sp2.PreferredSize = sp1.ContentSize * 1.2f;
            sp2.ContentSize = new CCSize(100, 100);
            sp2.Color = CCColor3B.Green;
            AddChild(sp2);
            sp2.RunAction(action);

        }
        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);
        }
        public SpriteBatchNodeChildrenScale()
        {
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/grossini_family.plist");

            var rot = new CCRotateBy (10, 360);

            seq = new CCRepeatForever(rot);

            // Children + Scale using Sprite
            // Test 1
            aParent = new CCNode();
            sprite1 = new CCSprite("grossinis_sister1.png");
            sprite2 = new CCSprite("grossinis_sister2.png");

            AddChild(aParent);
            aParent.AddChild(sprite1);
            sprite1.AddChild(sprite2);

            // Children + Scale using SpriteBatchNode
            // Test 2
            aParent2 = new CCSpriteBatchNode("animations/grossini_family");
            sprite3 = new CCSprite("grossinis_sister1.png");
            sprite4 = new CCSprite("grossinis_sister2.png");
            sprite4.Position = (new CCPoint(50, 0));

            AddChild(aParent2);
            aParent2.AddChild(sprite3);
            sprite3.AddChild(sprite4);

            // Children + Scale using Sprite
            // Test 3
            aParent3 = new CCNode ();
            sprite5 = new CCSprite("grossinis_sister1.png");
            sprite6 = new CCSprite("grossinis_sister2.png");

            AddChild(aParent3);
            aParent3.AddChild(sprite5);
            sprite5.AddChild(sprite6);

            // Children + Scale using Sprite
            // Test 4
            aParent4 = new CCSpriteBatchNode("animations/grossini_family");
            sprite7 = new CCSprite("grossinis_sister1.png");
            sprite8 = new CCSprite("grossinis_sister2.png");

            AddChild(aParent4);
            aParent4.AddChild(sprite7);
            sprite7.AddChild(sprite8);
        }
Пример #8
0
        public Atlas4()
        {
            m_time = 0;

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

			label.AnchorPoint = CCPoint.AnchorMiddle;


			var BChar = (CCSprite)label[0];
			var FChar = (CCSprite)label[7];
			var AChar = (CCSprite)label[12];


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

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

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

			var fade_out = new CCFadeOut  (1);
			var fade_in = new CCFadeIn  (1);
			var seq = new CCSequence(fade_out, fade_in);
			var fade_4ever = new CCRepeatForever (seq);

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


            // Bottom Label
			label2 = new CCLabelBMFont("00.0", "fonts/bitmapFontTest.fnt");
            AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);

			var lastChar = (CCSprite)label2[3];
            lastChar.RunAction(rot_4ever);

            //schedule( schedule_selector(Atlas4::step), 0.1f);
            base.Schedule(step, 0.1f);
        }
Пример #9
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);
        }
Пример #10
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            var label = new CCLabelBMFont("Enable AtlasItem", "fonts/bitmapFontTest3.fnt");
            var item1 = new CCMenuItemLabelBMFont(label, this.menuCallback2);

            CCMenuItemFont.FontSize = 28;
            CCMenuItemFont.FontName = "arial";

            var item2 = new CCMenuItemFont("--- Go Back ---", this.menuCallback);

            // We do not have an HD version of the menuitemsprite so internally CocosSharp tries to convert our
            // rectangle coordinates passed to work with HD images so the coordinates are off.  We will just 
            // modify this here to make sure we have the correct sizes when they are passed.
            var spriteNormal = new CCSprite(s_MenuItem, new CCRect(0, 23 * 2, 115, 23));
            var spriteSelected = new CCSprite(s_MenuItem, new CCRect(0, 23 * 1, 115, 23));
            var spriteDisabled = new CCSprite(s_MenuItem, new CCRect(0, 23 * 0, 115, 23));


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

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

            var s = Layer.VisibleBoundsWorldspace.Size;

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

            var jump = new CCJumpBy (3, new CCPoint(400, 0), 50, 4);
            item2.RepeatForever(jump, jump.Reverse());

            var spin1 = new CCRotateBy (3, 360);

            item1.RepeatForever(spin1);
            item2.RepeatForever(spin1);
            item3.RepeatForever(spin1);

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

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            // 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 = new CCMotionStreak(2, 3, 32, CCColor3B.Green, 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 ((CCFiniteTimeAction)new CCSequence(motion, motion.Reverse())));
            m_root.RunAction(action1);

            var colorAction = new CCRepeatForever ((CCFiniteTimeAction)
                new CCSequence(
                    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);
        }
Пример #12
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

			var listener = new CCEventListenerTouchAllAtOnce();
			listener.OnTouchesEnded = onTouchesEnded;

			AddEventListener(listener);    

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

			var rotate = new CCRotateBy (10, 360);

			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 = CCPoint.AnchorLowerLeft;
						break;
					case 1:
						sprite.AnchorPoint = CCPoint.AnchorMiddle;
						break;
					case 2:
						sprite.AnchorPoint = CCPoint.AnchorUpperRight;
						break;
				}

				point.Position = sprite.Position;

				sprite.RepeatForever(rotate);

				AddChild(sprite, i);
			}
		}
        public SpriteBatchNodeAnchorPoint()
        {
            sprites = new CCSprite[numOfSprites];
            pointSprites = new CCSprite[numOfSprites];

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

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

            for (int i = 0; i < numOfSprites; i++)
            {
                CCSprite sprite = new CCSprite(batch.Texture, new CCRect(85, 121 * 1, 85, 121));
                batch.AddChild(sprite, i);

                CCSprite point = new CCSprite("Images/r1");
                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;

                sprites[i] = sprite;
                pointSprites[i] = point;
            }
        }
Пример #14
0
        public override void OnEnter()
        {
base.OnEnter(); CCSize windowSize = Layer.VisibleBoundsWorldspace.Size;

            CCFiniteTimeAction action = new CCRotateBy(4, 360);

            for(int i = 0; i < numOfSprites; i++) 
            {
                float x = -1000;
                float y = -1000;

                if(CCRandom.NextDouble() < 0.2f)
                {
                    x = (float)(CCRandom.NextDouble() * windowSize.Width);
                    y = (float)(CCRandom.NextDouble() * windowSize.Height);
                }
                sprites[i].Position = (new CCPoint(x, y));

                sprites[i].RunAction(new CCRepeatForever(action));
            }

            Schedule(ReparentSprite, 2);
        }
Пример #15
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);
            }
        }
Пример #16
0
        public SpriteAnchorPoint()
        {
            sprites = new CCSprite[numOfSprites];
            pointSprites = new CCSprite[numOfSprites];

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


            for (int i = 0; i < numOfSprites; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85, 121 * 1, 85, 121));
                AddChild(sprite, i);

                CCSprite point = new CCSprite("Images/r1");
                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;

                sprites[i] = sprite;
                pointSprites[i] = point;
            }
        }
Пример #17
0
        void AddNewSprite()
        {
            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            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(texture1, new CCRect(x, y, 85, 121));
            node.AddChild(sprite);

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

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

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

            sprite.RunAction(new CCRepeatForever (seq));
        }
Пример #18
0
        public override void OnEnter()
        {
            base.OnEnter();

            Scene.PhysicsWorld.Gravity = CCPoint.Zero;

            //Create a boundin box container room
            var node = new CCNode();
            node.PhysicsBody = CCPhysicsBody.CreateEdgeBox(Window.WindowSizeInPixels, 1.0f, CCPoint.Zero);
            node.Position = Window.WindowSizeInPixels.Center;
            AddChild(node);

            //drops a grosini sprite on center on window
            CCSprite sp1 = AddGrossiniAtPosition(Center);
            CCSprite sp2 = AddGrossiniAtPosition(Left + new CCPoint(50, 0));
            CCSprite sp3 = AddGrossiniAtPosition(Right + new CCPoint(20, 0));
            CCSprite sp4 = AddGrossiniAtPosition(LeftTop + new CCPoint(50, -50));

            sp1.PhysicsBody.Tag = DRAG_BODYS_TAG;
            sp2.PhysicsBody.Tag = DRAG_BODYS_TAG;
            sp3.PhysicsBody.Tag = DRAG_BODYS_TAG;
            sp4.PhysicsBody.Tag = DRAG_BODYS_TAG;

            var actionTo = new CCJumpTo(2, new CCPoint(100, 100), 50, 4);
            var actionBy = new CCJumpTo(2, new CCPoint(300, 0), 50, 4);
            var actionUp = new CCJumpTo(2, new CCPoint(0, 50), 80, 4);
            var actionByBack = actionBy.Reverse();
            var rotateBy = new CCRotateBy(2, 180);
            var rotateByBack = new CCRotateBy(2, -180);

            sp1.RunAction(new CCRepeatForever(actionUp));
            sp2.RunAction(new CCRepeatForever(actionBy, actionByBack));
            sp3.RunAction(actionTo);
            sp4.RunAction(new CCRepeatForever(rotateBy, rotateByBack));

            ToggleDebug();

            Schedule();
        }
Пример #19
0
        public override void OnEnter()
        {
            base.OnEnter(); CCSize windowSize = Layer.VisibleBoundsWorldspace.Size;

            Color = new CCColor3B(0, 0, 0);
            RemoveChild(Background, true);
            Background = null;

            Emitter = new CCParticleSystemQuad(100, CCEmitterMode.Radius);
            AddChild(Emitter, 10);
            Emitter.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire");

            // duration
            Emitter.Duration = CCParticleSystem.ParticleDurationInfinity; 

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

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


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

            // emitter position
            CCSize size = WindowSize;
            Emitter.Position = new CCPoint(size.Width / 2, size.Height / 2);
            Emitter.PositionVar = new CCPoint(0, 0);

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

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

            // color of particles
            var startColor = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f);
            Emitter.StartColor = startColor;

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

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

            var endColorVar = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f);
            Emitter.EndColorVar = endColorVar;

            // size, in pixels
            Emitter.StartSize = 16;
            Emitter.StartSizeVar = 0;
            Emitter.EndSize = CCParticleSystem.ParticleStartSizeEqualToEndSize;

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

            // additive
            Emitter.BlendAdditive = false;

            CCRotateBy rot = new CCRotateBy (16, 360);
            Emitter.RunAction(new CCRepeatForever (rot));
        }
Пример #20
0
        public Issue1327()
        {
            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);

            actF = new CCSequence(act1, act2, act3, act4, act5, act6, act7, act8, act9);
        }
Пример #21
0
		private void resetMeteor()
		{
			//if too many objects on screen, return
			if (_fallingObjects.Count > 30) return;


			CCSprite meteor = _meteorPool[_meteorPoolIndex];
			_meteorPoolIndex++;
			if (_meteorPoolIndex == _meteorPool.Count) _meteorPoolIndex = 0;

			//pick start and target positions for new meteor
			int meteor_x = CCRandom.GetRandomInt(1, 1000) % (int)((_screenSize.Width * 0.8f) + _screenSize.Width * 0.1f);
			int meteor_target_x = CCRandom.GetRandomInt(1, 1000) % (int)((_screenSize.Width * 0.8f) + _screenSize.Width * 0.1f);

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

			//create action for meteor (rotate forever, move to target, and call function)
			CCRotateBy rotate = new CCRotateBy(0.5f, -90);
			CCAction repeatRotate = new CCRepeatForever(rotate);
			CCFiniteTimeAction sequence = new CCSequence(
					   new CCMoveTo(_meteorSpeed, new CCPoint(meteor_target_x, _screenSize.Height * 0.15f)),
					   new CCCallFuncN(fallingObjectDone));

			meteor.Visible = true;
			meteor.RunAction(repeatRotate);
			meteor.RunAction(sequence);
			_fallingObjects.Add(meteor);

		}
Пример #22
0
        public void delay2(float dt)
        {
            var node = (CCSprite) (GetChildByTag(2));
			var action1 = new CCRotateBy (1, 360);
            node.RunAction(action1);
        }
Пример #23
0
 public override void OnNodeLoaded(CCNode node, CCNodeLoader nodeLoader)
 {
     CCRotateBy ccRotateBy = new CCRotateBy (20.0f, 360);
     CCRepeatForever ccRepeatForever = new CCRepeatForever (ccRotateBy);
     mBurstSprite.RunAction(ccRepeatForever);
 }
Пример #24
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);

        }
Пример #25
0
        public TMXReadWriteTest() : base("TileMaps/orthogonal-test2")
        {
            m_gid = CCTileGidAndFlags.EmptyTile;

            CCTileMapLayer layer = tileMap.LayerNamed("Layer 0");
            layer.Antialiased = true;

            tileMap.Scale = (1);

            CCSprite tile0 = layer.ExtractTile(1, 63);
            CCSprite tile1 = layer.ExtractTile(2, 63);
            CCSprite tile2 = layer.ExtractTile(3, 62); //new CCPoint(1,62));
            CCSprite tile3 = layer.ExtractTile(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 sequence = new CCSequence(move, rotate, scale, opacity, fadein, scaleback, finish);

			tile0.RunAction(sequence);
			tile1.RunAction(sequence);
			tile2.RunAction(sequence);
			tile3.RunAction(sequence);


            m_gid = layer.TileGIDAndFlags(0, 63);

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


            m_gid2 = CCTileGidAndFlags.EmptyTile;
        }
Пример #26
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);
        }
Пример #27
0
        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;

            CCFiniteTimeAction 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();
            CCFiniteTimeAction action_back = (CCFiniteTimeAction)action.Reverse();
            CCFiniteTimeAction seq = (CCFiniteTimeAction)(new CCSequence(action, action_back));

            sprite.RunAction(new CCRepeatForever (seq));
        }
Пример #28
0
        public ActionRotationalSkewVSStandardSkew()
        {
            box1 = new CCDrawNode ();
            box1.DrawRect(new CCRect (0.0f, 0.0f, 200.0f, 200.0f), new CCColor4B(255, 255, 0, 255));
            //new CCLayerColor();
            this.AddChild(box1);

            box1.AnchorPoint = new CCPoint(0.5f, 0.5f);
            box1.IgnoreAnchorPointForPosition = false;

            box2 = new CCDrawNode ();
            box2.DrawRect(new CCRect (0.0f, 0.0f, 200.0f, 200.0f), new CCColor4B(255, 255, 0, 255));
            this.AddChild(box2);

            box2.AnchorPoint = new CCPoint(0.5f, 0.5f);
            box2.IgnoreAnchorPointForPosition = false;

            boxLabel1 = new CCLabelTtf("Standard cocos2d Skew", "Marker Felt", 16);
            this.AddChild(boxLabel1);

            boxLabel2 = new CCLabelTtf("Rotational Skew", "Marker Felt", 16);
            this.AddChild(boxLabel2);

            actionTo = new CCSkewBy(2, 360, 0);
            actionToBack = new CCSkewBy(2, -360, 0);

            actionTo2 = new CCRotateBy(2, 360, 0);
            actionToBack2 = new CCRotateBy(2, -360, 0);
        }
Пример #29
0
        public ActionTargeted()
        {
            var jump1 = new CCJumpBy(2, CCPoint.Zero, 100, 3);
            var rot1 = new CCRotateBy(1, 360);

            var t1 = new CCTargetedAction (Kathia, jump1);
            var t2 = new CCTargetedAction (Kathia, rot1);


            var seq = new CCSequence(jump1, t1, rot1, t2);
            always = new CCRepeatForever (seq);
        }
Пример #30
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();
 }