public SpriteChildrenVisibilityIssue665()
        {
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/grossini.plist");


            aParent = new CCSpriteBatchNode("animations/grossini", 50);
            AddChild(aParent, 0);

            sprite1 = new CCSprite("grossini_dance_01.png");
            sprite2 = new CCSprite("grossini_dance_02.png");
            sprite3 = new CCSprite("grossini_dance_03.png");

            // test issue #665
            sprite1.Visible = false;

            aParent.AddChild(sprite1);
            sprite1.AddChild(sprite2, -2);
            sprite1.AddChild(sprite3, 2);

            aParent2 = new CCNode();
            AddChild(aParent2, 0);

            sprite4 = new CCSprite("grossini_dance_01.png");
            sprite5 = new CCSprite("grossini_dance_02.png");
            sprite6 = new CCSprite("grossini_dance_03.png");

            // test issue #665
            sprite4.Visible = false;

            aParent2.AddChild(sprite4);
            sprite4.AddChild(sprite5, -2);
            sprite4.AddChild(sprite6, 2);
        }
        public SpriteChildrenAnchorPoint()
        {
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/grossini.plist");

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

            // anchor (0,0)
            sprite1 = new CCSprite("grossini_dance_08.png");
            sprite1.AnchorPoint = (new CCPoint(0, 0));
            sprite2 = new CCSprite("grossini_dance_02.png");
            sprite3 = new CCSprite("grossini_dance_03.png");
            sprite4 = new CCSprite("grossini_dance_04.png");

            aParent.AddChild(sprite1);
            sprite1.AddChild(sprite2, -2);
            sprite1.AddChild(sprite3, -2);
            sprite1.AddChild(sprite4, 3);

            point = new CCSprite("Images/r1");
            AddChild(point, 10);


            // anchor (0.5, 0.5)
            sprite5 = new CCSprite("grossini_dance_08.png");
            sprite5.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            sprite6 = new CCSprite("grossini_dance_02.png");
            sprite7 = new CCSprite("grossini_dance_03.png");
            sprite8 = new CCSprite("grossini_dance_04.png");

            aParent.AddChild(sprite5);
            sprite5.AddChild(sprite6, -2);
            sprite5.AddChild(sprite7, -2);
            sprite5.AddChild(sprite8, 3);

            point2 = new CCSprite("Images/r1");
            AddChild(point2, 10);

            // anchor (1,1)
            sprite9 = new CCSprite("grossini_dance_08.png");
            sprite9.AnchorPoint = new CCPoint(1, 1);
            sprite10 = new CCSprite("grossini_dance_02.png");
            sprite11 = new CCSprite("grossini_dance_03.png");
            sprite12 = new CCSprite("grossini_dance_04.png");

            aParent.AddChild(sprite9);
            sprite9.AddChild(sprite10, -2);
            sprite9.AddChild(sprite11, -2);
            sprite9.AddChild(sprite12, 3);

            point3 = new CCSprite("Images/r1");
            AddChild(point3, 10);
        }
        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 SpriteBatchNodeChildrenZ()
        {
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/grossini.plist");

            // test 1
            batch = new CCSpriteBatchNode("animations/grossini", 50);
            AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);

            sprite1 = new CCSprite("grossini_dance_01.png");
            sprite2 = new CCSprite("grossini_dance_02.png");
            sprite3 = new CCSprite("grossini_dance_03.png");

            batch.AddChild(sprite1);
            sprite1.AddChild(sprite2, 2);
            sprite1.AddChild(sprite3, -2);

            // test 2
            batch2 = new CCSpriteBatchNode("animations/grossini", 50);
            AddChild(batch2, 0, (int)kTags.kTagSpriteBatchNode);

            sprite4 = new CCSprite("grossini_dance_01.png");
            sprite5 = new CCSprite("grossini_dance_02.png");
            sprite6 = new CCSprite("grossini_dance_03.png");

            batch.AddChild(sprite4);
            sprite4.AddChild(sprite5, -2);
            sprite4.AddChild(sprite6, 2);

            // test 3
            batch3 = new CCSpriteBatchNode("animations/grossini", 50);
            AddChild(batch3, 0, (int)kTags.kTagSpriteBatchNode);

            sprite7 = new CCSprite("grossini_dance_01.png");
            sprite8 = new CCSprite("grossini_dance_02.png");
            sprite9 = new CCSprite("grossini_dance_03.png");

            batch3.AddChild(sprite7, 10);
            batch3.AddChild(sprite8, -10);
            batch3.AddChild(sprite9, -5);

            // test 4
            batch4 = new CCSpriteBatchNode("animations/grossini", 50);
            AddChild(batch4, 0, (int)kTags.kTagSpriteBatchNode);

            sprite10 = new CCSprite("grossini_dance_01.png");
            sprite11 = new CCSprite("grossini_dance_02.png");
            sprite12 = new CCSprite("grossini_dance_03.png");

            batch4.AddChild(sprite10, -10);
            batch4.AddChild(sprite11, -5);
            batch4.AddChild(sprite12, -2);
        }
        public SpriteBatchNodeChildrenAnchorPoint()
        {
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/grossini.plist");

            CCNode aParent;

            aParent = new CCSpriteBatchNode("animations/grossini", 50);
            AddChild(aParent, 0);

            sprite1 = new CCSprite("grossini_dance_08.png");
            sprite2 = new CCSprite("grossini_dance_02.png");
            sprite3 = new CCSprite("grossini_dance_03.png");
            sprite4 = new CCSprite("grossini_dance_04.png");

            aParent.AddChild(sprite1);
            sprite1.AddChild(sprite2, -2);
            sprite1.AddChild(sprite3, -2);
            sprite1.AddChild(sprite4, 3);

            point = new CCSprite("Images/r1");
            AddChild(point, 10);

            sprite5 = new CCSprite("grossini_dance_08.png");
            sprite6 = new CCSprite("grossini_dance_02.png");
            sprite7 = new CCSprite("grossini_dance_03.png");
            sprite8 = new CCSprite("grossini_dance_04.png");

            aParent.AddChild(sprite5);
            sprite5.AddChild(sprite6, -2);
            sprite5.AddChild(sprite7, -2);
            sprite5.AddChild(sprite8, 3);

            point2 = new CCSprite("Images/r1");
            AddChild(point2, 10);

            sprite9 = new CCSprite("grossini_dance_08.png");
            sprite10 = new CCSprite("grossini_dance_02.png");
            sprite11 = new CCSprite("grossini_dance_03.png");

            sprite12 = new CCSprite("grossini_dance_04.png");
            sprite12.Position = (new CCPoint(0, 0));
            sprite12.Scale = 0.5f;

            aParent.AddChild(sprite9);
            sprite9.AddChild(sprite10, -2);
            sprite9.AddChild(sprite11, -2);
            sprite9.AddChild(sprite12, 3);

            point3 = new CCSprite("Images/r1");
            AddChild(point3, 10);
        }
Esempio n. 6
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

			CCSprite p = new CCSprite(TestResource.s_back3);
			AddChild(p, 0);
			p.Position = (new CCPoint(s.Width / 2, s.Height / 2));
			//p.Opacity = 50;

			CCSprite sprite;
			CCOrbitCamera orbit;
			CCCamera cam;
			CCSize ss;

			// LEFT
			s = p.ContentSize;
			sprite = new CCSprite(TestResource.s_pPathGrossini);
			sprite.Scale = (0.5f);
			p.AddChild(sprite, 0);
			sprite.Position = (new CCPoint(s.Width / 4 * 1, s.Height / 2));
			cam = sprite.Camera;
			orbit = new CCOrbitCamera(2, 1, 0, 0, 360, 0, 0);
			sprite.RunAction(new CCRepeatForever (orbit));

			// CENTER
			sprite = new CCSprite(TestResource.s_pPathGrossini);
			sprite.Scale = 1.0f;
			p.AddChild(sprite, 0);
			sprite.Position = new CCPoint(s.Width / 4 * 2, s.Height / 2);
			orbit = new CCOrbitCamera(2, 1, 0, 0, 360, 45, 0);
			sprite.RunAction(new CCRepeatForever (orbit));


			// RIGHT
			sprite = new CCSprite(TestResource.s_pPathGrossini);
			sprite.Scale = 2.0f;
			p.AddChild(sprite, 0);
			sprite.Position = new CCPoint(s.Width / 4 * 3, s.Height / 2);
			ss = sprite.ContentSize;
			orbit = new CCOrbitCamera(2, 1, 0, 0, 360, 90, -45);
			sprite.RunAction(new CCRepeatForever (orbit));


			// PARENT
			orbit = new CCOrbitCamera(10, 1, 0, 0, 360, 0, 90);
			p.RunAction(new CCRepeatForever (orbit));
			Scale = 1;
		}
        CCSprite MakeSpriteZ(int aZ)
        {
            CCSprite sprite = new CCSprite(batchNode.Texture, new CCRect(128, 0, 64, 64));
            batchNode.AddChild(sprite, aZ + 1, 0);

            //children
            CCSprite spriteShadow = new CCSprite(batchNode.Texture, new CCRect(0, 0, 64, 64));
            spriteShadow.Opacity = 128;
            sprite.AddChild(spriteShadow, aZ, 3);

            CCSprite spriteTop = new CCSprite(batchNode.Texture, new CCRect(64, 0, 64, 64));
            sprite.AddChild(spriteTop, aZ + 2, 3);

            return sprite;
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
		public NodeToWorld3D()
		{
			//
			// This code tests that nodeToParent works OK:
			//  - It tests different anchor Points
			//  - It tests different children anchor points

			parent = new CCNode();
			parent.AnchorPoint = new CCPoint(0.5f, 0.5f);
			AddChild(parent);

			back = new CCSprite(TestResource.s_back3);
			parent.AddChild(back, -10);
			back.AnchorPoint = CCPoint.Zero;


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

			back.AddChild(menu);

			item.RepeatForever(CocosNodeTestStaticLibrary.nodeRotate);

			back.RepeatForever(CocosNodeTestStaticLibrary.nodeMove, CocosNodeTestStaticLibrary.nodeMove.Reverse());

			parent.RunAction (CocosNodeTestStaticLibrary.nodeOrbit);
		}
Esempio n. 10
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);
        }
Esempio n. 11
0
        public SpriteBatchNodeChildren()
        {
            CCSpriteBatchNode batch = new CCSpriteBatchNode("animations/grossini", 50);
            AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);

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

            sprite1 = new CCSprite("grossini_dance_01.png");
            sprite2 = new CCSprite("grossini_dance_02.png");
            sprite3 = new CCSprite("grossini_dance_03.png");

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

            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[str];
                animFrames.Add(frame);
            }

            animation = new CCAnimation(animFrames, 0.2f);

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

            seq2 = (CCFiniteTimeAction)action_rot.Reverse();
        }
        public SpriteBatchNodeReorderIssue767()
        {
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/ghosts.plist", "animations/ghosts");

            // SpriteBatchNode: 3 levels of children
            aParent = new CCSpriteBatchNode("animations/ghosts");
            AddChild(aParent, 0, (int) kTagSprite.kTagSprite1);

            // parent
            l1 = new CCSprite("father.gif");
            aParent.AddChild(l1, 0, (int) kTagSprite.kTagSprite2);

            // child left
            l2a = new CCSprite("sister1.gif");
            l1.AddChild(l2a, -1, (int) kTags.kTagSpriteLeft);


            // child right
            l2b = new CCSprite("sister2.gif");
            l1.AddChild(l2b, 1, (int) kTags.kTagSpriteRight);

            // child left bottom
            l3a1 = new CCSprite("child1.gif");
            l3a1.Scale = (0.65f);
            l2a.AddChild(l3a1, -1);

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

            // child right bottom
            l3b1 = new CCSprite("child1.gif");
            l3b1.Scale = (0.65f);
            l2b.AddChild(l3b1, -1);

            // child right top
            l3b2 = new CCSprite("child1.gif");
            l3b2.Scale = (0.65f);
            l2b.AddChild(l3b2, 1);

        }
        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);
        }
Esempio n. 14
0
        public CCControlStepper(CCSprite minusSprite, CCSprite plusSprite)
        {
            Debug.Assert(minusSprite != null, "Minus sprite must be not nil");
            Debug.Assert(plusSprite != null, "Plus sprite must be not nil");

            IsContinuous = true;
            IgnoreAnchorPointForPosition = false;
            autorepeat   = true;
            minimumValue = 0;
            maximumValue = 100;
            value        = 0;
            stepValue    = 1;
            wraps        = false;

            MinusSprite          = minusSprite;
            MinusSprite.Position = new CCPoint(minusSprite.ContentSize.Width / 2, minusSprite.ContentSize.Height / 2);
            AddChild(MinusSprite);

            MinusLabel          = new CCLabelTtf("-", ControlStepperLabelFont, 38);
            MinusLabel.Color    = ControlStepperLabelColorDisabled;
            MinusLabel.Position = new CCPoint(MinusSprite.ContentSize.Width / 2, MinusSprite.ContentSize.Height / 2);
            MinusSprite.AddChild(MinusLabel);

            PlusSprite          = plusSprite;
            PlusSprite.Position = new CCPoint(minusSprite.ContentSize.Width + plusSprite.ContentSize.Width / 2, minusSprite.ContentSize.Height / 2);
            AddChild(PlusSprite);

            PlusLabel          = new CCLabelTtf("+", ControlStepperLabelFont, 38);
            PlusLabel.Color    = ControlStepperLabelColorEnabled;
            PlusLabel.Position = PlusSprite.ContentSize.Center;
            PlusSprite.AddChild(PlusLabel);

            // Defines the content size
            CCRect maxRect = CCControlUtils.CCRectUnion(MinusSprite.BoundingBox, PlusSprite.BoundingBox);

            ContentSize = new CCSize(MinusSprite.ContentSize.Width + PlusSprite.ContentSize.Height, maxRect.Size.Height);

            // Register Touch Event
            var touchListener = new CCEventListenerTouchOneByOne();

            touchListener.IsSwallowTouches = true;

            touchListener.OnTouchBegan = OnTouchBegan;
            touchListener.OnTouchMoved = OnTouchMoved;
            touchListener.OnTouchEnded = OnTouchEnded;

            AddEventListener(touchListener);
        }
        private void AddCardinalImage(int p1, int p2) {
            var tmp = new CCSprite(Resources.BossCardinal) {
                Texture = {IsAntialiased = false},
                PositionX = p1,
                PositionY = p2,
                Scale = 6
            };

            var blades = new CCSprite(Resources.BossCardinalBlades) {
                Scale = 1,
                IsAntialiased = false,
                PositionX = tmp.Texture.PixelsWide/2,
                PositionY = tmp.Texture.PixelsHigh/2
            };

            blades.AddAction(new CCRepeatForever(new CCRotateBy(0.7f, -120)));
            tmp.AddChild(blades, -1);

            if (tmp.PositionX > Settings.ScreenWidth/2) {
                tmp.FlipX = true;
            }

            AddChild(tmp);
        }
Esempio n. 16
0
		public void createGameScreen()
		{

			CCSprite bg = new CCSprite("bg.png");
			bg.Position = new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.5f);
			AddChild(bg, kBackground);

			_lineContainer = LineContainer.Create();
			AddChild(_lineContainer);


			CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("sprite_sheet.plist");
			_gameBatchNode = new CCSpriteBatchNode("sprite_sheet.png", 100);

			AddChild(_gameBatchNode, kForeground);

			_rocket = Rocket.Create();
			_rocket.Position = new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.1f);
			_gameBatchNode.AddChild(_rocket, kForeground, kSpriteRocket);

			//add planets
			GameSprite planet;
			_planets = new List<GameSprite>();
			// _planets->retain();

			planet = new GameSprite("planet_1.png");
			planet.Position = new CCPoint(_screenSize.Width * 0.25f,
									_screenSize.Height * 0.8f);

			_gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
			_planets.Add(planet);

			planet = new GameSprite("planet_2.png");
			planet.Position = new CCPoint(_screenSize.Width * 0.8f,
									_screenSize.Height * 0.45f);
			_gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
			_planets.Add(planet);

			planet = new GameSprite("planet_3.png");
			planet.Position = new CCPoint(_screenSize.Width * 0.75f,
									_screenSize.Height * 0.8f);
			_gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
			_planets.Add(planet);

			planet = new GameSprite("planet_4.png");
			planet.Position = new CCPoint(_screenSize.Width * 0.5f,
									_screenSize.Height * 0.5f);
			_gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
			_planets.Add(planet);

			planet = new GameSprite("planet_5.png");
			planet.Position = new CCPoint(_screenSize.Width * 0.18f,
									_screenSize.Height * 0.45f);
			_gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
			_planets.Add(planet);

			planet = new GameSprite("planet_6.png");
			planet.Position = new CCPoint(_screenSize.Width * 0.8f,
									_screenSize.Height * 0.15f);
			_gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
			_planets.Add(planet);

			planet = new GameSprite("planet_7.png");
			planet.Position = new CCPoint(_screenSize.Width * 0.18f,
									_screenSize.Height * 0.1f);
			_gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
			_planets.Add(planet);

			CCSprite scoreLabel = new GameSprite("label_score.png");
			scoreLabel.Position = new CCPoint(_screenSize.Width * 0.4f, _screenSize.Height * 0.95f);
			_gameBatchNode.AddChild(scoreLabel, kBackground);

			_scoreDisplay = new CCLabelTtf("0", "MarkerFelt", 22);

			_scoreDisplay.AnchorPoint = new CCPoint(0, 0.5f);
			_scoreDisplay.Position = new CCPoint(_screenSize.Width * 0.48f, _screenSize.Height * 0.95f);
			AddChild(_scoreDisplay, kBackground);

			_pauseBtn = new GameSprite("btn_pause_off.png");
			_pauseBtn.Visible = false;
			_pauseBtn.Position = new CCPoint(_screenSize.Width * 0.06f, _screenSize.Height * 0.95f);
			_gameBatchNode.AddChild(_pauseBtn, kBackground);


			_intro = new GameSprite("logo.png");
			_intro.Position = new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.55f);
			CCSprite play = new CCSprite("label_play.png");
			play.Position = new CCPoint(_intro.BoundingBox.Size.Width * 0.5f, -_intro.BoundingBox.Size.Height * 0.5f);
			_intro.AddChild(play);
			_gameBatchNode.AddChild(_intro, kForeground);

			_gameOver = new GameSprite("gameOver.png");
			_gameOver.Position = new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.55f);
			_gameOver.Visible = false;
			_gameBatchNode.AddChild(_gameOver, kForeground);

			_paused = new GameSprite("label_paused.png");
			_paused.Position = new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.55f);
			_paused.Visible = false;
			_gameBatchNode.AddChild(_paused, kForeground);

		}
Esempio n. 17
0
        public override void OnEnter()
        {
            base.OnEnter(); CCSize windowSize = Layer.VisibleBoundsWorldspace.Size;

            Background.Parent.RemoveChild(Background, true);
            Background = null;

            CCParallaxNode p = new CCParallaxNode();
            AddChild(p, 5);

            CCSprite p1 = new CCSprite(TestResource.s_back3);
            CCSprite p2 = new CCSprite(TestResource.s_back3);

            p.AddChild(p1, 1, new CCPoint(0.5f, 1), new CCPoint(0, 250));
            p.AddChild(p2, 2, new CCPoint(1.5f, 1), new CCPoint(0, 50));

            Emitter = new CCParticleFlower(MidWindowPoint);

            Emitter.Texture = CCTextureCache.SharedTextureCache.AddImage(TestResource.s_fire);

            p1.AddChild(Emitter, 10);
            Emitter.Position = new CCPoint(250, 200);

            CCParticleSun par = new CCParticleSun(MidWindowPoint);
            p2.AddChild(par, 10);
            par.Texture = CCTextureCache.SharedTextureCache.AddImage(TestResource.s_fire);

            CCFiniteTimeAction move = new CCMoveBy (4, new CCPoint(300, 0));
            CCFiniteTimeAction move_back = move.Reverse();
            CCFiniteTimeAction seq = new CCSequence(move, move_back);
            p.RunAction(new CCRepeatForever ((CCFiniteTimeAction) seq));
        }
		public override void OnEnter ()
		{
			base.OnEnter ();

            CCRect visibleBounds = Layer.VisibleBoundsWorldspace;
			var origin = Layer.VisibleBoundsWorldspace.Origin;
			var size = Layer.VisibleBoundsWorldspace.Size;

			var sprite1 = new CCSprite("Images/CyanSquare.png");
			sprite1.Position = origin + new CCPoint (size.Width / 2, size.Height / 2) + new CCPoint (-80, 80);
			AddChild(sprite1, 10);

			var sprite2 = new CCSprite("Images/MagentaSquare.png");
			sprite2.Position = origin + new CCPoint (size.Width / 2, size.Height / 2);
			AddChild(sprite2, 20);

			var sprite3 = new CCSprite("Images/YellowSquare.png");
			sprite3.Position = CCPoint.Zero;
			sprite2.AddChild(sprite3, 1);

			// Make sprite1 touchable
			var listener1 = new CCEventListenerTouchOneByOne ();
			listener1.IsSwallowTouches = true;

			listener1.OnTouchBegan = (touch, touchEvent) => 
			{
				var target = (CCSprite)touchEvent.CurrentTarget;

				var locationInNode = target.Layer.ScreenToWorldspace(touch.LocationOnScreen);
				var s = target.ContentSize;
                CCRect rect = target.BoundingBoxTransformedToWorld;

				if (rect.ContainsPoint(locationInNode))
				{
					CCLog.Log("sprite began... x = {0}, y = {1}", locationInNode.X, locationInNode.Y);
					target.Opacity = 180;
					return true;
				}
				return false;
			};

			listener1.OnTouchMoved = (touch, touchEvent) => 
			{
				var target = (CCSprite)touchEvent.CurrentTarget;
                CCPoint pt = touch.PreviousLocationOnScreen + touch.Delta;
                target.Position = target.WorldToParentspace(Layer.ScreenToWorldspace(pt));
			};

			listener1.OnTouchEnded = (touch, touchEvent) => 
			{
				var target = (CCSprite)touchEvent.CurrentTarget;
				CCLog.Log("sprite onTouchesEnded..");
				target.Opacity = 255;
				if (target == sprite2)
				{
					sprite1.LocalZOrder = 100;
				}
				else if(target == sprite1)
				{
					sprite1.LocalZOrder = 0;
				}
			};


            sprite1.AddEventListener(listener1);
            sprite2.AddEventListener(listener1.Copy());
            sprite3.AddEventListener(listener1.Copy());


			var removeAllTouchItem = new CCMenuItemFont("Remove All Touch Listeners", (sender) => {
				var senderItem = (CCMenuItemFont)sender;
				senderItem.LabelTTF.Text = "Only Next item could be clicked";

                RemoveEventListeners(CCEventListenerType.TOUCH_ONE_BY_ONE);

				var nextItem = new CCMenuItemFont("Next", (senderNext) => NextCallback(senderNext));
			

				CCMenuItemFont.FontSize = 16;
                nextItem.Position =  new CCPoint(visibleBounds.Origin.X + visibleBounds.Size.Width -100, 100);

				var menu2 = new CCMenu(nextItem);
				menu2.Position = CCPoint.Zero;
				menu2.AnchorPoint = CCPoint.AnchorLowerLeft;
				this.AddChild(menu2);
			});

			CCMenuItemFont.FontSize = 16;
            removeAllTouchItem.Position = new CCPoint(visibleBounds.Origin.X + visibleBounds.Size.Width -100, 80);

			var menu = new CCMenu(removeAllTouchItem);
			menu.Position = CCPoint.Zero;
			menu.AnchorPoint = CCPoint.AnchorLowerLeft;
			AddChild(menu);


		}
Esempio n. 19
0
		private void createGameScreen()
		{

			//add bg
			CCSprite bg = new CCSprite("bg");
			bg.Position = new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.5f);
			AddChild(bg);

			//create spritebatch node
			CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("sprite_sheet.plist");

			_gameBatchNode = new CCSpriteBatchNode("sprite_sheet.png");

			//ProcessSprite(_gameBatchNode);
			//_gameBatchNode.BlendFunc = new CCBlendFunc(blendSrc, blendDst);
			AddChild(_gameBatchNode);

			//create cityscape
			CCSprite sprite;
			for (int i = 0; i < 2; i++)
			{

				sprite = new CCSprite("city_dark.png"); //new CCSprite("city_dark.png");
				//sprite.BlendFunc = new CCBlendFunc(blendSrc, blendDst);
				ProcessSprite(sprite);

				sprite.Position = new CCPoint(_screenSize.Width * (0.25f + i * 0.5f),
									  sprite.BoundingBox.Size.Height * 0.5f);

				_gameBatchNode.AddChild(sprite, kForeground);

				sprite = new CCSprite("city_light.png");// new CCSprite("city_light.png");
				//sprite.BlendFunc = new CCBlendFunc(blendSrc, blendDst);
				ProcessSprite(sprite);

				sprite.Position = new CCPoint(_screenSize.Width * (0.25f + i * 0.5f),
									  sprite.BoundingBox.Size.Height * 0.9f);

				_gameBatchNode.AddChild(sprite, kBackground);

			}

			//add trees
			for (int i = 0; i < 3; i++)
			{

				sprite = new CCSprite("trees.png");// new CCSprite("trees.png");

				//sprite.BlendFunc = new CCBlendFunc(blendSrc, blendDst);
				ProcessSprite(sprite);

				sprite.Position = new CCPoint(_screenSize.Width * (0.2f + i * 0.3f),
										sprite.BoundingBox.Size.Height * 0.5f);

				_gameBatchNode.AddChild(sprite, kForeground);

			}

			//add HUD
			_scoreDisplay = new CCLabelTtf("0", "MarkerFelt", 22);
			_scoreDisplay.AnchorPoint = new CCPoint(1f, 0.5f);
			_scoreDisplay.Position = new CCPoint(_screenSize.Width * 0.8f, _screenSize.Height * 0.94f);
			AddChild(_scoreDisplay);

			_energyDisplay = new CCLabelTtf("100%", "MarkerFelt", 22);
			_energyDisplay.Position = new CCPoint(_screenSize.Width * 0.3f, _screenSize.Height * 0.94f);
			AddChild(_energyDisplay);

			CCSprite icon = new CCSprite("health_icon.png"); // new CCSprite("health_icon.png");
			icon.Position = new CCPoint(_screenSize.Width * 0.15f, _screenSize.Height * 0.94f);

			//icon.BlendFunc = new CCBlendFunc(blendSrc, blendDst);
			ProcessSprite(icon);

			_gameBatchNode.AddChild(icon, kBackground);

			//add clouds
			CCSprite cloud;
			_clouds = new List<CCSprite>(4);
			//_clouds

			float cloud_y;
			for (int i = 0; i < 4; i++)
			{
				cloud_y = i % 2 == 0 ? _screenSize.Height * 0.4f : _screenSize.Height * 0.5f;
				cloud = new CCSprite(CCSpriteFrameCache.SharedSpriteFrameCache["cloud.png"]); // new CCSprite("cloud.png");
				ProcessSprite(cloud);
				//cloud.BlendFunc = new CCBlendFunc(blendSrc, blendDst);
				cloud.Position = new CCPoint(_screenSize.Width * 0.1f + i * _screenSize.Width * 0.3f, cloud_y);
				_gameBatchNode.AddChild(cloud, kBackground);
				_clouds.Add(cloud);
			}

			//CREATE BOMB SPRITE
			_bomb = new CCSprite("bomb.png");
			//_bomb.BlendFunc = new CCBlendFunc(blendSrc, blendDst);
			ProcessSprite(_bomb);
			//_bomb.Texture.GenerateMipmap();
			_bomb.Visible = false;

			CCSize size = _bomb.BoundingBox.Size;

			//add sparkle inside bomb sprite
			CCSprite sparkle = new CCSprite("sparkle.png");
			//sparkle.BlendFunc = new CCBlendFunc(blendSrc, blendDst);
			ProcessSprite(sparkle);
			sparkle.Position = new CCPoint(size.Width * 0.72f, size.Height * 0.72f);
			_bomb.AddChild(sparkle, kMiddleground, kSpriteSparkle);


			//add halo inside bomb sprite
			CCSprite halo = new CCSprite("halo.png");
			//halo.BlendFunc = new CCBlendFunc(blendSrc, blendDst);
			ProcessSprite(halo);
			halo.Position = new CCPoint(size.Width * 0.4f, size.Height * 0.4f);
			_bomb.AddChild(halo, kMiddleground, kSpriteHalo);
			_gameBatchNode.AddChild(_bomb, kForeground);

			//add shockwave
			_shockWave = new CCSprite("shockwave.png");
			//_shockWave.BlendFunc = new CCBlendFunc(blendSrc, blendDst);
			ProcessSprite(_shockWave);

			_shockWave.Visible = false;
			_gameBatchNode.AddChild(_shockWave);

			//intro message
			_introMessage = new CCSprite("logo.png");
			//_introMessage.BlendFunc = new CCBlendFunc(blendSrc, blendDst);
			ProcessSprite(_introMessage);
			_introMessage.Position = new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.6f);
			_introMessage.Visible = true;
			AddChild(_introMessage, kForeground);

			//game over message
			_gameOverMessage = new CCSprite("gameover.png");
			_gameOverMessage.Position = new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.65f);

			//_gameOverMessage.BlendFunc = new CCBlendFunc(blendSrc, blendDst);
			ProcessSprite(_gameOverMessage);
			_gameOverMessage.Visible = false;
			AddChild(_gameOverMessage, kForeground);

		}
Esempio n. 20
0
        public CCControlStepper(CCSprite minusSprite, CCSprite plusSprite)
        {
            Debug.Assert(minusSprite != null, "Minus sprite must be not nil");
            Debug.Assert(plusSprite != null, "Plus sprite must be not nil");

			IsContinuous = true;
			IgnoreAnchorPointForPosition = false;
            autorepeat = true;
            minimumValue = 0;
            maximumValue = 100;
            value = 0;
            stepValue = 1;
            wraps = false;

            MinusSprite = minusSprite;
			MinusSprite.Position = new CCPoint(minusSprite.ContentSize.Width / 2, minusSprite.ContentSize.Height / 2);
            AddChild(MinusSprite);

            MinusLabel = new CCLabelTtf("-", ControlStepperLabelFont, 38);
            MinusLabel.Color = ControlStepperLabelColorDisabled;
			MinusLabel.Position = new CCPoint(MinusSprite.ContentSize.Width / 2, MinusSprite.ContentSize.Height / 2);
            MinusSprite.AddChild(MinusLabel);

            PlusSprite = plusSprite;
			PlusSprite.Position = new CCPoint(minusSprite.ContentSize.Width + plusSprite.ContentSize.Width / 2, minusSprite.ContentSize.Height / 2);
            AddChild(PlusSprite);

            PlusLabel = new CCLabelTtf("+", ControlStepperLabelFont, 38);
            PlusLabel.Color = ControlStepperLabelColorEnabled;
            PlusLabel.Position = PlusSprite.ContentSize.Center;
            PlusSprite.AddChild(PlusLabel);

            // Defines the content size
            CCRect maxRect = CCControlUtils.CCRectUnion(MinusSprite.BoundingBox, PlusSprite.BoundingBox);
            ContentSize = new CCSize(MinusSprite.ContentSize.Width + PlusSprite.ContentSize.Height, maxRect.Size.Height);

			// Register Touch Event
			var touchListener = new CCEventListenerTouchOneByOne();
			touchListener.IsSwallowTouches = true;

			touchListener.OnTouchBegan = OnTouchBegan;
			touchListener.OnTouchMoved = OnTouchMoved;
			touchListener.OnTouchEnded = OnTouchEnded;

            AddEventListener(touchListener);
        }