コード例 #1
0
ファイル: TextLayer.cs プロジェクト: h7ing/CocosSharp
		public TextLayer() : base()
		{

            contentLayer = new CCLayer();
            CCCamera contentCamera = Camera;
            contentLayer.Camera = contentCamera;

            var bg = new CCSprite(TestResource.s_back3);
            BaseNode = bg;
            contentLayer.AddChild(bg, 0, EffectTestScene.kTagBackground);

            var Kathia = new CCSprite(TestResource.s_pPathSister2);
            BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);

            var sc = new CCScaleBy(2, 5);
            var sc_back = sc.Reverse();
            Kathia.RunAction(new CCRepeatForever(sc, sc_back));


            var Tamara = new CCSprite(TestResource.s_pPathSister1);
            BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);

            var sc2 = new CCScaleBy(2, 5);
            var sc2_back = sc2.Reverse();
            Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));

            var colorBackground = new CCLayerColor(new CCColor4B(32, 128, 32, 255));
            contentLayer.AddChild(colorBackground, -1);
		}
コード例 #2
0
ファイル: SpriteZVertex.cs プロジェクト: h7ing/CocosSharp
        protected override void AddedToScene()
        {
            base.AddedToScene();

            contentLayer = new CCLayer();
            Window.IsUseDepthTesting = true;
            node = new CCNode(Layer.VisibleBoundsWorldspace.Size);
            node.AnchorPoint = CCPoint.AnchorMiddle;
            node.IgnoreAnchorPointForPosition = true;

            AddChild(contentLayer);
            contentLayer.AddChild(node);

            dir = 1;
            time = 0;
            sprites = new CCSprite[numOfSprites];


            for (int i = 0; i < 5; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121));
                node.AddChild(sprite, 0);
                sprites[i] = sprite;
            }

            for (int i = 5; i < 11; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 0, 85, 121));
                node.AddChild(sprite, 0);
                sprites[i] = sprite;
            }
        }
コード例 #3
0
        public SpriteChildrenVisibility()
        {
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/grossini.plist");

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

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

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

            aParent.AddChild(sprite4);
            sprite4.AddChild(sprite5, -2);
            sprite4.AddChild(sprite6, 2);
        }
コード例 #4
0
ファイル: TextLayer.cs プロジェクト: netonjm/CocosSharp
		public TextLayer() : base()
		{

            Camera = AppDelegate.SharedCamera;
            contentLayer = new CCLayer();
            CCCamera contentCamera = new CCCamera(Camera.OrthographicViewSizeWorldspace, Camera.CenterInWorldspace, Camera.TargetInWorldspace);
            contentLayer.Camera = contentCamera;

            var bg = new CCSprite(TestResource.s_back3);
            BaseNode = bg;
            contentLayer.AddChild(bg, 0, EffectTestScene.kTagBackground);

            var Kathia = new CCSprite(TestResource.s_pPathSister2);
            BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);

            var sc = new CCScaleBy(2, 5);
            var sc_back = sc.Reverse();
            Kathia.RunAction(new CCRepeatForever(sc, sc_back));


            var Tamara = new CCSprite(TestResource.s_pPathSister1);
            BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);

            var sc2 = new CCScaleBy(2, 5);
            var sc2_back = sc2.Reverse();
            Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));

            var colorBackground = new CCLayerColor(new CCColor4B(32, 128, 32, 255));
            contentLayer.AddChild(colorBackground, -1);
		}
コード例 #5
0
        public SpriteZVertex()
        {
            //
            // This test tests z-order
            // If you are going to use it is better to use a 3D projection
            //
            // WARNING:
            // The developer is resposible for ordering it's sprites according to it's Z if the sprite has
            // transparent parts.
            //

            dir = 1;
            time = 0;
            sprites = new CCSprite[numOfSprites];

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

            for (int i = 0; i < 5; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121));
                node.AddChild(sprite, 0);
                sprites[i] = sprite;
            }

            for (int i = 5; i < 11; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 0, 85, 121));
                node.AddChild(sprite, 0);
                sprites[i] = sprite;
            }
        }
コード例 #6
0
        public TextLayer() : base()
        {
            contentLayer = new CCLayer();
            CCCamera contentCamera = new CCCamera(Camera.OrthographicViewSizeWorldspace, Camera.CenterInWorldspace, Camera.TargetInWorldspace);

            contentLayer.Camera = contentCamera;

            var bg = new CCSprite(TestResource.s_back3);

            BaseNode = bg;
            contentLayer.AddChild(bg, 0, EffectTestScene.kTagBackground);

            var Kathia = new CCSprite(TestResource.s_pPathSister2);

            BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);

            var sc      = new CCScaleBy(2, 5);
            var sc_back = sc.Reverse();

            Kathia.RunAction(new CCRepeatForever(sc, sc_back));


            var Tamara = new CCSprite(TestResource.s_pPathSister1);

            BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);

            var sc2      = new CCScaleBy(2, 5);
            var sc2_back = sc2.Reverse();

            Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));

            var colorBackground = new CCLayerColor(new CCColor4B(32, 128, 32, 255));

            contentLayer.AddChild(colorBackground, -1);
        }
コード例 #7
0
        public TextLayer() : base()
        {
            var backGround = new CCLayerColor(new CCColor4B(32, 128, 32, 255));

            AddChild(backGround, -20);

            BaseNode = new CCNode();
            var bg = new CCSprite(TestResource.s_back3);

            BaseNode.ContentSize = bg.ContentSize;
            BaseNode.AddChild(bg, 0, EffectTestScene.kTagBackground);

            var Kathia = new CCSprite(TestResource.s_pPathSister2);

            BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);

            var sc      = new CCScaleBy(2, 5);
            var sc_back = sc.Reverse();

            Kathia.RunAction(new CCRepeatForever(sc, sc_back));


            var Tamara = new CCSprite(TestResource.s_pPathSister1);

            BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);

            var sc2      = new CCScaleBy(2, 5);
            var sc2_back = sc2.Reverse();

            Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));

            AddChild(BaseNode);
        }
コード例 #8
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            contentLayer             = new CCLayer();
            Window.IsUseDepthTesting = true;
            node             = new CCNode(Layer.VisibleBoundsWorldspace.Size);
            node.AnchorPoint = CCPoint.AnchorMiddle;
            node.IgnoreAnchorPointForPosition = true;

            AddChild(contentLayer);
            contentLayer.AddChild(node);

            dir     = 1;
            time    = 0;
            sprites = new CCSprite[numOfSprites];


            for (int i = 0; i < 5; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121));
                node.AddChild(sprite, 0);
                sprites[i] = sprite;
            }

            for (int i = 5; i < 11; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 0, 85, 121));
                node.AddChild(sprite, 0);
                sprites[i] = sprite;
            }
        }
コード例 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Core.Button"/> class.
        /// </summary>
        /// <param name="father">Father node for the button.</param>
        /// <param name="tl">Touch listener.</param>
        /// <param name="method">Method to call when the button is pressed. Must be coherent with the delegate <see cref="Core.touchList.eventHandlerTouch"/>.</param>
        /// <param name="textureDefault">Texture for normal state.</param>
        /// <param name="texturePressed">Texture for pressed state.</param>
        /// <param name="position">Position of the button.</param>
        /// <param name="winSize">Window size.</param>
        /// <param name="rot">Rotation of the button.</param>
        /// <param name="scale">Scale of the button.</param>
        /// <param name="order">ZOrder (depth).</param>
        internal CCButton(CCNode father, TouchList tl, TouchList.eventHandlerTouch method, string textureDefault, string texturePressed, CCPoint position, CCSize winSize, float rot = -90, float scale = 0.55f, int order = 0)
        {
            //Defining the sprite
            _spriteNorm          = new CCSprite(textureDefault);
            _spriteNorm.Position = position;
            _spriteNorm.Rotation = rot;
            _spriteNorm.Scale    = scale;
            father.AddChild(_spriteNorm);

            _spritePressed          = new CCSprite(texturePressed);
            _spritePressed.Position = position;
            _spritePressed.Rotation = rot;
            _spritePressed.Scale    = scale;
            father.AddChild(_spritePressed);
            _spritePressed.Visible = false;

            this._winSize = winSize;
            this._father  = father;

            //Defining the event variables
            _onButtonPressed        = method;
            _pressed                = false;
            _touch                  = tl;
            _touch.eventTouchBegan += touchBegan;
            _touch.eventTouchEnded += touchEnded;
        }
コード例 #10
0
        public static CCNode CreateLabel(string text, float size, CCColor3B color, CCColor3B shadowColor)
        {
            var node = new CCNode () {
                AnchorPoint = CCPoint.AnchorMiddle,
            };


            size *= 1.2f;

            var lbl = new CCLabel(text, "fonts/MorrisRoman-Black.ttf", size, CCLabelFormat.SystemFont)
                {
                    Color = color,
                    AnchorPoint = CCPoint.AnchorMiddle,
                };
            lbl.LabelFormat.Alignment = CCTextAlignment.Center;

            node.ContentSize = lbl.ScaledContentSize;
            lbl.Position = node.ContentSize.Center;

            if (shadowColor != CCColor3B.Magenta)
            {
                node.ContentSize = lbl.ContentSize + 2;
                var shadowLbl = new CCLabel (text, "fonts/MorrisRoman-Black.ttf", size, CCLabelFormat.SystemFont) {
                    Color = shadowColor,
                    AnchorPoint = CCPoint.AnchorMiddle,
                    Position = new CCPoint(node.ContentSize.Center.X + 2, node.ContentSize.Center.Y - 2)
                };
                shadowLbl.LabelFormat.Alignment = CCTextAlignment.Center;
                node.AddChild (shadowLbl);
            }
            node.AddChild (lbl);
            return node;
        }
コード例 #11
0
        public SpriteChildrenVisibility()
        {
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/grossini.plist");

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

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

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

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

        }
コード例 #12
0
        public TextLayer()
        {
            InitWithColor(CCTypes.CreateColor(32, 32, 32, 255));

            var node = new CCNode();
            CCActionInterval effect = getAction();

            node.RunAction(effect);
            AddChild(node, 0, EffectTestScene.kTagBackground);

            var bg = new CCSprite(TestResource.s_back3);

            node.AddChild(bg, 0);
            bg.AnchorPoint = new CCPoint(0.5f, 0.5f);
            bg.Position    = CCVisibleRect.Center;

            var grossini = new CCSprite(TestResource.s_pPathSister2);

            node.AddChild(grossini, 1);
            grossini.Position = new CCPoint(CCVisibleRect.Left.X + CCVisibleRect.VisibleRect.Size.Width / 3,
                                            CCVisibleRect.Center.Y);
            CCActionInterval   sc      = new CCScaleBy(2, 5);
            CCFiniteTimeAction sc_back = sc.Reverse();

            grossini.RunAction(new CCRepeatForever((new CCSequence(sc, sc_back))));

            var tamara = new CCSprite(TestResource.s_pPathSister1);

            node.AddChild(tamara, 1);
            tamara.Position = new CCPoint(CCVisibleRect.Left.X + 2 * CCVisibleRect.VisibleRect.Size.Width / 3,
                                          CCVisibleRect.Center.Y);
            CCActionInterval   sc2      = new CCScaleBy(2, 5);
            CCFiniteTimeAction sc2_back = sc2.Reverse();

            tamara.RunAction(new CCRepeatForever((new CCSequence(sc2, sc2_back))));

            var label = new CCLabelTTF(EffectTestScene.effectsList[EffectTestScene.actionIdx], "arial", 32);

            label.Position = new CCPoint(CCVisibleRect.Center.X, CCVisibleRect.Top.Y - 80);
            AddChild(label);
            label.Tag = EffectTestScene.kTagLabel;

            var item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback);
            var item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback);
            var item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback);

            var menu = new CCMenu(item1, item2, item3);

            menu.Position  = CCPoint.Zero;
            item1.Position = new CCPoint(CCVisibleRect.Center.X - item2.ContentSize.Width * 2,
                                         CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2);
            item2.Position = new CCPoint(CCVisibleRect.Center.X, CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2);
            item3.Position = new CCPoint(CCVisibleRect.Center.X + item2.ContentSize.Width * 2,
                                         CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2);

            AddChild(menu, 1);

            Schedule(checkAnim);
        }
コード例 #13
0
        public override void OnEnter()
        {
            base.OnEnter();

            var screenSize = Layer.VisibleBoundsWorldspace.Size;

            var layer = new CCNode();

            layer.Position = screenSize.Center;
            AddChild(layer, 1);

            var layerWidth = 0.0f;

            // Add the black background for the text
            var background = new CCScale9SpriteFile("extensions/buttonBackground");

            background.ContentSize = new CCSize(80, 50);
            background.Position    = new CCPoint(layerWidth + background.ContentSize.Width / 2.0f, 0);
            layer.AddChild(background);

            layerWidth += background.ContentSize.Width;

            DisplayValueLabel = new CCLabel("#color", "Arial", 30, CCLabelFormat.SpriteFont);

            DisplayValueLabel.Position = background.Position;
            layer.AddChild(DisplayValueLabel);

            // Create the switch
            CCControlSwitch switchControl = new CCControlSwitch
                                            (
                new CCSprite("extensions/switch-mask"),
                new CCSprite("extensions/switch-on"),
                new CCSprite("extensions/switch-off"),
                new CCSprite("extensions/switch-thumb"),
                new CCLabel("On", "Arial", 16, CCLabelFormat.SpriteFont),
                new CCLabel("Off", "Arial", 16, CCLabelFormat.SpriteFont)
                                            );

            switchControl.Position = new CCPoint(layerWidth + 10 + switchControl.ContentSize.Width / 2, 0);
            layer.AddChild(switchControl);

            // Subscribe to the switches StateChanged event
            switchControl.StateChanged += SwitchControl_StateChanged;

            // --------------- OR ---------------------
            // we can subscribe to the ValueChanged event.
            //switchControl.ValueChanged += SwitchControl_ValueChanged;



            // Set the layer size
            layer.ContentSize = new CCSize(layerWidth, 0);
            layer.AnchorPoint = CCPoint.AnchorMiddle;

            // Update the value label
            ValueChanged(switchControl, CCControlEvent.ValueChanged);
        }
コード例 #14
0
        public override void OnEnter()
        {
            base.OnEnter();

            var screenSize = Layer.VisibleBoundsWorldspace.Size;

            var layer = new CCNode ();
            layer.Position = screenSize.Center;
            AddChild(layer, 1);

            var layerWidth = 0.0f;

            // Add the black background for the text
            var background = new CCScale9SpriteFile("extensions/buttonBackground");
            background.ContentSize = new CCSize(80, 50);
            background.Position = new CCPoint(layerWidth + background.ContentSize.Width / 2.0f, 0);
            layer.AddChild(background);

            layerWidth += background.ContentSize.Width;

            DisplayValueLabel = new CCLabel("#color", "Arial", 30, CCLabelFormat.SpriteFont);

            DisplayValueLabel.Position = background.Position;
            layer.AddChild(DisplayValueLabel);

            // Create the switch
            CCControlSwitch switchControl = new CCControlSwitch
                (
                    new CCSprite("extensions/switch-mask"),
                    new CCSprite("extensions/switch-on"),
                    new CCSprite("extensions/switch-off"),
                    new CCSprite("extensions/switch-thumb"),
                    new CCLabel("On", "Arial", 16, CCLabelFormat.SpriteFont),
                    new CCLabel("Off", "Arial", 16, CCLabelFormat.SpriteFont)
                );
            switchControl.Position = new CCPoint(layerWidth + 10 + switchControl.ContentSize.Width / 2, 0);
            layer.AddChild(switchControl);

            // Subscribe to the switches StateChanged event
            switchControl.StateChanged += SwitchControl_StateChanged;

            // --------------- OR ---------------------
            // we can subscribe to the ValueChanged event.
            //switchControl.ValueChanged += SwitchControl_ValueChanged;



            // Set the layer size
            layer.ContentSize = new CCSize(layerWidth, 0);
            layer.AnchorPoint = CCPoint.AnchorMiddle;

            // Update the value label
            ValueChanged(switchControl, CCControlEvent.ValueChanged);
        }
コード例 #15
0
        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);
        }
コード例 #16
0
        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);
        }
コード例 #17
0
        public override bool Init()
        {
            if (base.Init())
            {
                CCSize screenSize = CCDirector.SharedDirector.WinSize;

                CCNode layer = new CCNode();
                layer.Position = new CCPoint(screenSize.Width / 2, screenSize.Height / 2);
                AddChild(layer, 1);

                float layer_width = 0;

                // Create the colour picker
                CCControlColourPicker colourPicker = new CCControlColourPicker();
                colourPicker.Color    = new CCColor3B(37, 46, 252);
                colourPicker.Position = new CCPoint(colourPicker.ContentSize.Width / 2, 0);

                // Add it to the layer
                layer.AddChild(colourPicker);

                // Add the target-action pair
                colourPicker.AddTargetWithActionForControlEvents(this, ColourValueChanged,
                                                                 CCControlEvent.ValueChanged);


                layer_width += colourPicker.ContentSize.Width;

                // Add the black background for the text
                CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground.png");
                background.ContentSize = new CCSize(150, 50);
                background.Position    = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0);
                layer.AddChild(background);

                layer_width += background.ContentSize.Width;

                _colorLabel = new CCLabelTTF("#color", "Arial", 26);

                _colorLabel.Position = background.Position;
                layer.AddChild(_colorLabel);

                // Set the layer size
                layer.ContentSize = new CCSize(layer_width, 0);
                layer.AnchorPoint = new CCPoint(0.5f, 0.5f);

                // Update the color text
                ColourValueChanged(colourPicker, CCControlEvent.ValueChanged);
                return(true);
            }
            return(false);
        }
コード例 #18
0
        public override bool Init()
        {
            if (base.Init())
            {
                CCSize screenSize = CCDirector.SharedDirector.WinSize;

                CCNode layer = new CCNode();
                layer.Position = new CCPoint(screenSize.Width / 2, screenSize.Height / 2);
                AddChild(layer, 1);

                float layer_width = 0.0f;

                // Add the black background for the text
                CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground");
                background.ContentSize = new CCSize(80, 50);
                background.Position    = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0);
                layer.AddChild(background);

                layer_width += background.ContentSize.Width;

                m_pDisplayValueLabel = new CCLabelTTF("#color", "Marker Felt", 30);

                m_pDisplayValueLabel.Position = background.Position;
                layer.AddChild(m_pDisplayValueLabel);

                // Create the switch
                CCControlSwitch switchControl = new CCControlSwitch
                                                (
                    new CCSprite("extensions/switch-mask"),
                    new CCSprite("extensions/switch-on"),
                    new CCSprite("extensions/switch-off"),
                    new CCSprite("extensions/switch-thumb"),
                    new CCLabelTTF("On", "Arial-BoldMT", 16),
                    new CCLabelTTF("Off", "Arial-BoldMT", 16)
                                                );
                switchControl.Position = new CCPoint(layer_width + 10 + switchControl.ContentSize.Width / 2, 0);
                layer.AddChild(switchControl);

                switchControl.AddTargetWithActionForControlEvents(this, valueChanged, CCControlEvent.ValueChanged);

                // Set the layer size
                layer.ContentSize = new CCSize(layer_width, 0);
                layer.AnchorPoint = new CCPoint(0.5f, 0.5f);

                // Update the value label
                valueChanged(switchControl, CCControlEvent.ValueChanged);
                return(true);
            }
            return(false);
        }
コード例 #19
0
        public override void OnEnter()
        {
            base.OnEnter();

            var screenSize = Layer.VisibleBoundsWorldspace.Size;

            var layer = new CCNode();

            layer.Position = screenSize.Center;
            AddChild(layer, 1);

            double layer_width = 0;

            // Add the black background for the text
            CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground.png");

            background.ContentSize = new CCSize(80, 50);
            background.Position    = new CCPoint((float)layer_width + background.ContentSize.Width / 2.0f, 0);
            layer.AddChild(background);

            layer_width += background.ContentSize.Width;

            DisplayValueLabel = new CCLabel("", "Arial", 30);

            DisplayValueLabel.Position = background.Position;
            layer.AddChild(DisplayValueLabel);

            // Add the slider
            var potentiometer = new CCControlPotentiometer("extensions/potentiometerTrack.png"
                                                           ,
                                                           "extensions/potentiometerProgress.png"
                                                           , "extensions/potentiometerButton.png");

            potentiometer.Position = new CCPoint((float)layer_width + 10 + potentiometer.ContentSize.Width / 2, 0);

            // When the value of the slider will change, the given selector will be call
            potentiometer.ValueChanged += Potentiometer_ValueChanged;

            layer.AddChild(potentiometer);

            layer_width += potentiometer.ContentSize.Width;

            // Set the layer size
            layer.ContentSize = new CCSize((float)layer_width, 0);
            layer.AnchorPoint = CCPoint.AnchorMiddle;

            // Update the value label
            ValueChanged(potentiometer, CCControlEvent.ValueChanged);
        }
コード例 #20
0
        public override bool Init()
        {
            if (base.Init())
            {
                CCSize screenSize = CCDirector.SharedDirector.WinSize;

                var layer = new CCNode();
                layer.Position = new CCPoint(screenSize.Width / 2, screenSize.Height / 2);
                AddChild(layer, 1);

                double layer_width = 0;

                // Add the black background for the text
                CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground.png");
                background.ContentSize = new CCSize(80, 50);
                background.Position    = new CCPoint((float)layer_width + background.ContentSize.Width / 2.0f, 0);
                layer.AddChild(background);

                layer_width += background.ContentSize.Width;

                DisplayValueLabel = new CCLabelTTF("", "Arial", 30);

                _displayValueLabel.Position = background.Position;
                layer.AddChild(_displayValueLabel);

                // Add the slider
                var potentiometer = new CCControlPotentiometer("extensions/potentiometerTrack.png"
                                                               ,
                                                               "extensions/potentiometerProgress.png"
                                                               , "extensions/potentiometerButton.png");
                potentiometer.Position = new CCPoint((float)layer_width + 10 + potentiometer.ContentSize.Width / 2, 0);

                // When the value of the slider will change, the given selector will be call
                potentiometer.AddTargetWithActionForControlEvents(this, ValueChanged, CCControlEvent.ValueChanged);

                layer.AddChild(potentiometer);

                layer_width += potentiometer.ContentSize.Width;

                // Set the layer size
                layer.ContentSize = new CCSize((float)layer_width, 0);
                layer.AnchorPoint = new CCPoint(0.5f, 0.5f);

                // Update the value label
                ValueChanged(potentiometer, CCControlEvent.ValueChanged);
                return(true);
            }
            return(false);
        }
コード例 #21
0
        public CCControlSwitchTest()
        {
            CCSize screenSize = Layer.VisibleBoundsWorldspace.Size;

            CCNode layer = new CCNode();

            layer.Position = new CCPoint(screenSize.Width / 2, screenSize.Height / 2);
            AddChild(layer, 1);

            float layer_width = 0.0f;

            // Add the black background for the text
            CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground");

            background.ContentSize = new CCSize(80, 50);
            background.Position    = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0);
            layer.AddChild(background);

            layer_width += background.ContentSize.Width;

            m_pDisplayValueLabel = new CCLabelTtf("#color", "Arial", 30);

            m_pDisplayValueLabel.Position = background.Position;
            layer.AddChild(m_pDisplayValueLabel);

            // Create the switch
            CCControlSwitch switchControl = new CCControlSwitch
                                            (
                new CCSprite("extensions/switch-mask"),
                new CCSprite("extensions/switch-on"),
                new CCSprite("extensions/switch-off"),
                new CCSprite("extensions/switch-thumb"),
                new CCLabelTtf("On", "Arial", 16),
                new CCLabelTtf("Off", "Arial", 16)
                                            );

            switchControl.Position = new CCPoint(layer_width + 10 + switchControl.ContentSize.Width / 2, 0);
            layer.AddChild(switchControl);

            switchControl.AddTargetWithActionForControlEvents(this, valueChanged, CCControlEvent.ValueChanged);

            // Set the layer size
            layer.ContentSize = new CCSize(layer_width, 0);
            layer.AnchorPoint = new CCPoint(0.5f, 0.5f);

            // Update the value label
            valueChanged(switchControl, CCControlEvent.ValueChanged);
        }
コード例 #22
0
        public CCControlColourPickerTest()
        {
            CCSize screenSize = Layer.VisibleBoundsWorldspace.Size;

            CCNode layer = new CCNode();

            layer.Position = new CCPoint(screenSize.Width / 2, screenSize.Height / 2);
            AddChild(layer, 1);

            float layer_width = 0;

            // Create the colour picker
            CCControlColourPicker colourPicker = new CCControlColourPicker();

            colourPicker.Color    = new CCColor3B(37, 46, 252);
            colourPicker.Position = new CCPoint(colourPicker.ContentSize.Width / 2, 0);

            // Add it to the layer
            layer.AddChild(colourPicker);

            // Add the target-action pair
            colourPicker.AddTargetWithActionForControlEvents(this, ColourValueChanged,
                                                             CCControlEvent.ValueChanged);


            layer_width += colourPicker.ContentSize.Width;

            // Add the black background for the text
            CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground.png");

            background.ContentSize = new CCSize(150, 50);
            background.Position    = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0);
            layer.AddChild(background);

            layer_width += background.ContentSize.Width;

            _colorLabel = new CCLabelTtf("#color", "Arial", 26);

            _colorLabel.Position = background.Position;
            layer.AddChild(_colorLabel);

            // Set the layer size
            layer.ContentSize = new CCSize(layer_width, 0);
            layer.AnchorPoint = new CCPoint(0.5f, 0.5f);

            // Update the color text
            ColourValueChanged(colourPicker, CCControlEvent.ValueChanged);
        }
コード例 #23
0
        public override void OnEnter()
        {
            base.OnEnter();

            var screenSize = Layer.VisibleBoundsWorldspace.Size;

            CCNode layer = new CCNode();

            layer.Position = screenSize.Center;
            AddChild(layer, 1);

            float layer_width = 0;

            // Create the colour picker
            CCControlColourPicker colourPicker = new CCControlColourPicker();

            colourPicker.Color    = new CCColor3B(37, 46, 252);
            colourPicker.Position = new CCPoint(colourPicker.ContentSize.Width / 2, 0);

            // Add it to the layer
            layer.AddChild(colourPicker);

            // Add the target-action pair
            colourPicker.ValueChanged += ColourValueChanged;

            layer_width += colourPicker.ContentSize.Width;

            // Add the black background for the text
            CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground.png");

            background.ContentSize = new CCSize(150, 50);
            background.Position    = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0);
            layer.AddChild(background);

            layer_width += background.ContentSize.Width;

            ColorLabel = new CCLabel("#color", "Arial", 26, CCLabelFormat.SpriteFont);

            ColorLabel.Position = background.Position;
            layer.AddChild(ColorLabel);

            // Set the layer size
            layer.ContentSize = new CCSize(layer_width, 0);
            layer.AnchorPoint = new CCPoint(0.5f, 0.5f);

            // Update the color text
            ColourValueChanged(colourPicker, CCControlEvent.ValueChanged);
        }
コード例 #24
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            var s = VisibleBoundsWorldspace.Size;

            var parent = new CCNode();

            parent.Position = new CCPoint(s.Width / 2, s.Height / 2);
            AddChild(parent);

            var rectNode = new CCDrawNode();

            CCPoint[] rectangle = new CCPoint []
            {
                new CCPoint(-50, -50),
                new CCPoint(50, -50),
                new CCPoint(50, 50),
                new CCPoint(-50, 50)
            };

            var white = new CCColor4F(1, 1, 1, 1);

            rectNode.DrawPolygon(rectangle, 4, white, 1, white);
            parent.AddChild(rectNode);
        }
コード例 #25
0
ファイル: Issue631.cs プロジェクト: ununian/CocosSharp
        public override void OnEnter()
        {
            base.OnEnter();

            var effect = new CCSequence(new CCDelayTime(2.0f), new CCShaky3D(5.0f, new CCGridSize(5, 5), 16, false));

            // cleanup
            RemoveChild(bgNode, true);

            // background
            var layer = new CCLayerColor(new CCColor4B(255, 0, 0, 255));

            AddChild(layer, -10);
            var sprite = new CCSprite("Images/grossini");

            sprite.Position = new CCPoint(50, 80);
            layer.AddChild(sprite, 10);

            // foreground
            var layer2Node = new CCNode();
            var layer2     = new CCLayerColor(new CCColor4B(0, 255, 0, 255));
            var fog        = new CCSprite("Images/Fog");

            var bf = new CCBlendFunc {
                Source = CCOGLES.GL_SRC_ALPHA, Destination = CCOGLES.GL_ONE_MINUS_SRC_ALPHA
            };

            fog.BlendFunc = bf;
            layer2.AddChild(fog, 1);
            AddChild(layer2Node, 1);
            layer2Node.AddChild(layer2);

            layer2Node.RepeatForever(effect);
        }
コード例 #26
0
ファイル: NodeToWorld.cs プロジェクト: h7ing/CocosSharp
		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);
		}
コード例 #27
0
ファイル: CCTileMap.cs プロジェクト: KevinHeyer/CocosSharp
        public CCTileMap(CCTileMapInfo mapInfo)
            : base(CCCameraProjection.Projection2D)
        {
            Type = mapInfo.MapType;
            MapDimensions = mapInfo.MapDimensions;
            MapInfo = mapInfo;
            TileTexelSize = mapInfo.TileTexelSize;

            ObjectGroups = mapInfo.ObjectGroups;
            MapProperties = mapInfo.MapProperties;
            TileProperties = mapInfo.TileProperties;

            TileLayersContainer
                = new CCNode(MapDimensions.Size * TileTexelSize * CCTileMapLayer.DefaultTexelToContentSizeRatios);

            AddChild(TileLayersContainer);

            int idx = 0;

            List<CCTileLayerInfo> layers = mapInfo.Layers;
            if (layers != null)
            {
                foreach (CCTileLayerInfo layerInfo in layers)
                {
                    if (layerInfo.Visible)
                    {
                        CCTileSetInfo[] tilesets = TilesetsForLayer(layerInfo);
                        CCTileMapLayer child = new CCTileMapLayer(tilesets, layerInfo, mapInfo);
                        TileLayersContainer.AddChild(child, idx, idx);

                        idx++;
                    }
                }
            }
        }
コード例 #28
0
        public SpriteChildrenVisibilityIssue665()
        {
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/grossini.plist");


            aParent = new CCSprite("animations/grossini");

            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;

            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);
        }
コード例 #29
0
ファイル: Issue631.cs プロジェクト: KerwinMa/CocosSharp
        public override void OnEnter()
        {
            base.OnEnter();

			var effect = new CCSequence(new CCDelayTime (2.0f), new CCShaky3D(5.0f, new CCGridSize(5, 5), 16, false));

            // cleanup
			RemoveChild(bgNode, true);

            // background
			var layer = new CCLayerColor(new CCColor4B(255, 0, 0, 255));
            AddChild(layer, -10);
			var sprite = new CCSprite("Images/grossini");
            sprite.Position = new CCPoint(50, 80);
            layer.AddChild(sprite, 10);

            // foreground
			var layer2Node = new CCNode ();
			var layer2 = new CCLayerColor(new CCColor4B(0, 255, 0, 255));
			var fog = new CCSprite("Images/Fog");

			var bf = new CCBlendFunc {Source = CCOGLES.GL_SRC_ALPHA, Destination = CCOGLES.GL_ONE_MINUS_SRC_ALPHA};
			fog.BlendFunc = bf;
			layer2.AddChild(fog, 1);
			AddChild(layer2Node, 1);
			layer2Node.AddChild (layer2);

			layer2Node.RepeatForever(effect);
        }
コード例 #30
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);
        }
コード例 #31
0
        public override void Setup()
        {
            const int depth = 9;

            CCNode parent = this;

            for (int i = 0; i < depth; i++)
            {
                int size = 225 - i * (225 / (depth * 2));

                CCClippingNode clipper = new CCClippingNode();
                clipper.ContentSize    = new CCSize(size, size);
                clipper.AnchorPoint    = new CCPoint(0.5f, 0.5f);
                clipper.Position       = new CCPoint(parent.ContentSize.Width / 2, parent.ContentSize.Height / 2);
                clipper.AlphaThreshold = 0.05f;
                clipper.RunAction(new CCRepeatForever(new CCRotateBy(i % 3 != 0 ? 1.33f : 1.66f, i % 2 != 0 ? 90 : -90)));
                parent.AddChild(clipper);

                CCNode stencil = new CCSprite(TestResource.s_pPathGrossini);
                stencil.Scale       = 2.5f - (i * (2.5f / depth));
                stencil.AnchorPoint = new CCPoint(0.5f, 0.5f);
                stencil.Position    = new CCPoint(clipper.ContentSize.Width / 2, clipper.ContentSize.Height / 2);
                stencil.Visible     = false;
                stencil.RunAction(new CCSequence(new CCDelayTime(i), new CCShow()));
                clipper.Stencil = stencil;

                clipper.AddChild(stencil);

                parent = clipper;
            }
        }
コード例 #32
0
        private void CreateTheButtons()
        {
            CCNode theLayer = GetChildByTag(kTheLayer);

            theLayer.RemoveAllChildrenByTag(kTheButtons);
            int space = 10; // px

            max_w = 0f;
            max_h = 0f;

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    // Add the buttons
                    var button = standardButtonWithTitle(CCRandom.Next(30).ToString());
                    button.SetAdjustBackgroundImage(false);  // Tells the button that the background image must not be adjust
                    // It'll use the prefered size of the background image
                    button.Position = new CCPoint(button.ContentSize.Width / 2 + (button.ContentSize.Width + space) * i,
                                                  button.ContentSize.Height / 2 + (button.ContentSize.Height + space) * j);
                    theLayer.AddChild(button, kTheButtons);

                    max_w = Math.Max(button.ContentSize.Width * (i + 1) + space * i, max_w);
                    max_h = Math.Max(button.ContentSize.Height * (j + 1) + space * j, max_h);
                }
            }
        }
コード例 #33
0
ファイル: LabelBMFontHD.cs プロジェクト: krashman/cocos2d-xna
 public override void Update(float dt)
 {
     elapsed += dt;
     if (elapsed > 1f)
     {
         elapsed = 0f;
         // CCLabelBMFont
         if (label1 != null)
         {
             RemoveChild(label1);
         }
         CCNode node = new CCNode();
         CCSize s    = CCDirector.SharedDirector.WinSize;
         float  x    = s.Width * CCMacros.CCRandomBetween0And1();
         float  y    = s.Height * CCMacros.CCRandomBetween0And1();
         label1 = new CCLabelBMFont(string.Format("{0:N2},{1:N2} @ Mem Leak Ctor", x, y), "fonts/konqa32.fnt", 255f, CCTextAlignment.Right, CCPoint.Zero);
         node.AddChild(label1);
         label1.Position = new CCPoint(x, y);
         AddChild(node);
         label1 = node;
         // Start - test case for memory leak mentioned at https://cocos2dxna.codeplex.com/discussions/544032
         node.Scale = 2f;
         //--> This action causes the leak
         CCScaleTo    acScale   = new CCScaleTo(0.1f, 1);
         CCDelayTime  acShow    = new CCDelayTime(0.1f);
         CCSplitRows  acFadeOut = new CCSplitRows(0.1f, 20);
         CCRemoveSelf acRemove  = new CCRemoveSelf(true);
         CCSequence   seq       = new CCSequence(acScale, acShow, acFadeOut, acRemove);
         node.RunAction(seq);
     }
 }
コード例 #34
0
        public LHSprite(CCSpriteFrame spriteFrame, PlistDictionary dict, CCNode prnt, String spriteFrameName, String imageDevPath) : base(spriteFrame)
        {
            Debug.WriteLine("DID INIT SPRITE WITH FRAME " + spriteFrame);

            this._spriteFrameName = spriteFrameName;
            this._imageFilePath   = imageDevPath;


            prnt.AddChild(this);

//				[self setColor:[dict colorForKey:@"colorOverlay"]];
//
            _nodeProtocolImp.loadGenericInfoFromDictionary(dict, this);

            Debug.WriteLine("LOADING PHYSICS...................");
            Debug.WriteLine("SPR NAME " + this.getSpriteFrameName());
            Debug.WriteLine("IMG NAME " + this.getImageFilePath());
            Debug.WriteLine(dict);

            _physicsProtocolImp.loadPhysicsInfoFromDictionary(dict["nodePhysics"].AsDictionary, this);


            LHNodeProtocolImp.loadChildrenForNode(this, dict);
//
//
//				_animationProtocolImp = [[LHNodeAnimationProtocolImp alloc] initAnimationProtocolImpWithDictionary:dict
//					node:self];
//			}
//
        }
コード例 #35
0
ファイル: MenuLayer.cs プロジェクト: j-mathes/BubbleBreak
//		//---------------------------------------------------------------------------------------------------------
//		// ReadBranches
//		//---------------------------------------------------------------------------------------------------------
//		// Reads the contents of the branches.xml file and builds a list of branch objects
//		//---------------------------------------------------------------------------------------------------------
//		public List<Branch> ReadBranches(XDocument branchInfo)
//		{
//			branchInfo = XDocument.Load (LEVEL_DATA_FOLDER + "branches.xml");
//			List<Branch> branchList = (from branch in branchInfo.Root.Descendants ("record")
//				select new Branch {
//					BranchNum = int.Parse (branch.Element ("BranchNum").Value),
//					BranchName = branch.Element ("BranchName").Value,
//					NumberOfLevels = int.Parse (branch.Element ("NumberOfLevels").Value),
//					UnlockNextBranch = int.Parse (branch.Element ("UnlockNextBranch").Value),
//					UnlockFreePlay = int.Parse (branch.Element ("UnlockFreePlay").Value),
//				}).ToList ();
//			return branchList;
//		}
//
//		//---------------------------------------------------------------------------------------------------------
//		// ReadLevels
//		//---------------------------------------------------------------------------------------------------------
//		// Using the list of branches, reads each individual level xml file and builds a list of level objects
//		//---------------------------------------------------------------------------------------------------------
//		public List<Level> ReadLevels(XDocument levelData)
//		{
//			levelData = XDocument.Load (LEVEL_DATA_FOLDER + "levels.xml");
//
//			List<Level> lvl = (from level in levelData.Root.Descendants ("record")
//				select new Level {
//					BranchNum = int.Parse (level.Element ("BranchNum").Value),
//					LevelNum = int.Parse (level.Element ("LevelNum").Value),
//					LevelName = level.Element ("LevelName").Value,
//					MaxBubbles = int.Parse (level.Element ("MaxBubbles").Value),
//					MaxVisibleBubbles = int.Parse (level.Element ("MaxVisibleBubbles").Value),
//					StartingPointValue = int.Parse (level.Element ("StartingPointValue").Value),
//					MaxLevelTime = int.Parse (level.Element ("MaxLevelTime").Value),
//					LevelPassScore = int.Parse (level.Element ("LevelPassScore").Value),
//					TapsToPopStandard = int.Parse (level.Element ("TapsToPopStandard").Value),
//					InitialVisibleBubbles = int.Parse (level.Element ("InitialVisibleBubbles").Value),
//					ChanceToRollNextSeq = int.Parse (level.Element ("ChanceToRollNextSeq").Value),
//					ChanceToRollBonus = int.Parse (level.Element ("ChanceToRollBonus").Value),
//					LevelDescription = level.Element ("LevelDescription").Value,
//					SeqLinear = bool.Parse (level.Element ("SeqLinear").Value),
//					SeqEven = bool.Parse ( level.Element ("SeqEven").Value),
//					SeqOdd = bool.Parse (level.Element ("SeqOdd").Value),
//					SeqTriangular = bool.Parse (level.Element ("SeqTriangular").Value),
//					SeqSquare = bool.Parse (level.Element ("SeqSquare").Value),
//					SeqLazy = bool.Parse (level.Element ("SeqLazy").Value),
//					SeqFibonacci = bool.Parse (level.Element ("SeqFibonacci").Value),
//					SeqPrime = bool.Parse (level.Element ("SeqPrime").Value),
//					SeqDouble = bool.Parse (level.Element ("SeqDouble").Value),
//					SeqTriple = bool.Parse (level.Element ("SeqTriple").Value),
//					SeqPi = bool.Parse (level.Element ("SeqPi").Value),
//					SeqRecaman = bool.Parse (level.Element ("SeqRecaman").Value),
//					ConsumablesCheckpoints = int.Parse (level.Element ("ConsumablesCheckpoints").Value),
//					ConsumablesAdditions = int.Parse (level.Element ("ConsumablesAdditions").Value),
//					ConsumablesSubtractions = int.Parse (level.Element ("ConsumablesSubtractions").Value),
//					ConsumablesNexts = int.Parse (level.Element ("ConsumablesNexts").Value),
//					BonusDoubleScore = bool.Parse (level.Element ("BonusDoubleScore").Value),
//					BonusTripleScore = bool.Parse (level.Element ("BonusTripleScore").Value),
//					BonusCheckpoint = bool.Parse (level.Element ("BonusCheckpoint").Value),
//					BonusPosTime = bool.Parse (level.Element ("BonusPosTime").Value),
//					BonusPosPoints = bool.Parse (level.Element ("BonusPosPoints").Value),
//					BonusTapStrength = bool.Parse (level.Element ("BonusTapStrength").Value),
//					BonusAddition = bool.Parse (level.Element ("BonusAddition").Value),
//					BonusSubtraction = bool.Parse (level.Element ("BonusSubtraction").Value),
//					BonusNextMF = bool.Parse (level.Element ("BonusNextMF").Value),
//					BonusBonusMF = bool.Parse (level.Element ("BonusBonusMF").Value),
//					BonusNextInSeq = bool.Parse (level.Element ("BonusNextInSequence").Value),
//					BonusMystery = bool.Parse (level.Element ("BonusMystery").Value),
//		UnlockSequenceUI = bool.Parse (level.Element ("UnlockSequenceUI").Value),
//		UnlockBonusUI = bool.Parse (level.Element ("UnlockBonusUI").Value),
//		UnlockConsumableUI = bool.Parse (level.Element ("UnlockConsumableUI").Value),
//				}).ToList ();
//			return lvl;
//		}

        //---------------------------------------------------------------------------------------------------------
        // CheckForFadedBubbles
        //---------------------------------------------------------------------------------------------------------
        // Check to see if a bubble faded and died.  If so, replace it
        //---------------------------------------------------------------------------------------------------------
        void CheckForFadedBubbles()
        {
            //check if a bubble has popped on its own
            if (Bubbles.ChildrenCount < visibleBubbles)
            {
                var newBubbleOrder = new ShuffleBag <int> ();

                for (int i = 0; i < BubbleOccupiedArray.Length; i++)
                {
                    if (!BubbleOccupiedArray [i])
                    {
                        newBubbleOrder.Add(i);
                    }
                }

                var     newBubbleIndex = newBubbleOrder.Next();
                var     newBubble      = new MenuBubble((newBubbleIndex % MAX_BUBBLES_X), (newBubbleIndex / MAX_BUBBLES_X), newBubbleIndex);
                CCPoint p = GetRandomPosition(newBubble.XIndex, newBubble.YIndex);
                newBubble.Position = new CCPoint(p.X, p.Y);
                newBubble.Scale    = BUBBLE_SCALE;
                DisplayBubble(newBubble);
                Bubbles.AddChild(newBubble);
                BubbleOccupiedArray [newBubbleIndex] = true;
            }
        }
コード例 #36
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize screenSize = Layer.VisibleBoundsWorldspace.Size;

            // Defines an array of title to create buttons dynamically
            var stringArray = new[] {
                "Hello",
                "Variable",
                "Size",
                "!"
            };

            CCNode layer = new CCNode ();
            AddChild(layer, 1);

            float total_width = 0, height = 0;

            // For each title in the array
            int i = 0;
            foreach(var title in stringArray)
            {
                // Creates a button with this string as title
                var button = standardButtonWithTitle(title);
                if (i == 0)
                {
                    button.Opacity = 50;
                    button.Color = new CCColor3B(0, 255, 0);
                }
                else if (i == 1)
                {
                    button.Opacity = 200;
                    button.Color = new CCColor3B(0, 255, 0);
                }
                else if (i == 2)
                {
                    button.Opacity = 100;
                    button.Color = new CCColor3B(0, 0, 255);
                }

                button.Position = new CCPoint (total_width + button.ContentSize.Width / 2, button.ContentSize.Height / 2);
                layer.AddChild(button);

                // Compute the size of the layer
                height = button.ContentSize.Height;
                total_width += button.ContentSize.Width;
                i++;
            }

            layer.AnchorPoint = new CCPoint(0.5f, 0.5f);
            layer.ContentSize = new CCSize(total_width, height);
            layer.Position = new CCPoint(screenSize.Width / 2.0f, screenSize.Height / 2.0f);

            // Add the black background
            var background = new CCScale9SpriteFile("extensions/buttonBackground");
            background.ContentSize = new CCSize(total_width + 14, height + 14);
            background.Position = new CCPoint(screenSize.Width / 2.0f, screenSize.Height / 2.0f);
            AddChild(background);
        }
コード例 #37
0
        private void DisplayHint()
        {
            _isDisplayingHint = true;

            var idx = FindMove();
            var x   = idx % Constants.KBoardWidth;
            var y   = (int)Math.Floor((double)idx / Constants.KBoardWidth);

            var connected = FindConnectedGems(x, y);

            for (var i = 0; i < connected.Count; i++)
            {
                idx = connected[i];
                x   = idx % Constants.KBoardWidth;
                y   = (int)Math.Floor((double)idx / Constants.KBoardWidth);

                var actionFadeIn  = new CCFadeIn(0.5f);
                var actionFadeOut = new CCFadeOut(0.5f);
                var actionSeq     = new CCSequence(actionFadeIn, actionFadeOut);
                var action        = new CCRepeatForever(actionSeq);

                var hintSprite = new CCSprite("crystalscrystals/hint.png");
                hintSprite.Opacity     = 0;
                hintSprite.Position    = new CCPoint(_fieldPositionZero.X + x * Constants.KGemSize, _fieldPositionZero.Y + y * Constants.KGemSize);
                hintSprite.AnchorPoint = CCPoint.Zero;
                _hintLayer.AddChild(hintSprite);
                hintSprite.RunAction(action);
            }
        }
コード例 #38
0
        public override void OnEnter()
        {
            base.OnEnter();

            var screenSize = Layer.VisibleBoundsWorldspace.Size;

            var layer = new CCNode();
            layer.Position = screenSize.Center;
            AddChild(layer, 1);

            double layer_width = 0;

            // Add the black background for the text
            CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground.png");
            background.ContentSize = new CCSize(80, 50);
            background.Position = new CCPoint((float) layer_width + background.ContentSize.Width / 2.0f, 0);
            layer.AddChild(background);

            layer_width += background.ContentSize.Width;

            DisplayValueLabel = new CCLabel("", "Arial", 30);

            DisplayValueLabel.Position = background.Position;
            layer.AddChild(DisplayValueLabel);

            // Add the slider
            var potentiometer = new CCControlPotentiometer("extensions/potentiometerTrack.png"
                ,
                "extensions/potentiometerProgress.png"
                , "extensions/potentiometerButton.png");
            potentiometer.Position = new CCPoint((float) layer_width + 10 + potentiometer.ContentSize.Width / 2, 0);

            // When the value of the slider will change, the given selector will be call
            potentiometer.ValueChanged += Potentiometer_ValueChanged;

            layer.AddChild(potentiometer);

            layer_width += potentiometer.ContentSize.Width;

            // Set the layer size
            layer.ContentSize = new CCSize((float) layer_width, 0);
            layer.AnchorPoint = CCPoint.AnchorMiddle;

            // Update the value label
            ValueChanged(potentiometer, CCControlEvent.ValueChanged);

        }
コード例 #39
0
        public CCControlSwitchTest()
        {
            CCSize screenSize = Layer.VisibleBoundsWorldspace.Size;

            CCNode layer = new CCNode ();
            layer.Position = new CCPoint(screenSize.Width / 2, screenSize.Height / 2);
            AddChild(layer, 1);

            float layer_width = 0.0f;

            // Add the black background for the text
            CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground");
            background.ContentSize = new CCSize(80, 50);
            background.Position = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0);
            layer.AddChild(background);

            layer_width += background.ContentSize.Width;

            m_pDisplayValueLabel = new CCLabelTtf("#color", "Arial", 30);

            m_pDisplayValueLabel.Position = background.Position;
            layer.AddChild(m_pDisplayValueLabel);

            // Create the switch
            CCControlSwitch switchControl = new CCControlSwitch
                (
                    new CCSprite("extensions/switch-mask"),
                    new CCSprite("extensions/switch-on"),
                    new CCSprite("extensions/switch-off"),
                    new CCSprite("extensions/switch-thumb"),
                    new CCLabelTtf("On", "Arial", 16),
                    new CCLabelTtf("Off", "Arial", 16)
                );
            switchControl.Position = new CCPoint(layer_width + 10 + switchControl.ContentSize.Width / 2, 0);
            layer.AddChild(switchControl);

            switchControl.AddTargetWithActionForControlEvents(this, valueChanged, CCControlEvent.ValueChanged);

            // Set the layer size
            layer.ContentSize = new CCSize(layer_width, 0);
            layer.AnchorPoint = new CCPoint(0.5f, 0.5f);

            // Update the value label
            valueChanged(switchControl, CCControlEvent.ValueChanged);
        }
コード例 #40
0
        public CCControlColourPickerTest()
        {
            CCSize screenSize = Layer.VisibleBoundsWorldspace.Size;

            CCNode layer = new CCNode();
            layer.Position = new CCPoint(screenSize.Width / 2, screenSize.Height / 2);
            AddChild(layer, 1);

            float layer_width = 0;

            // Create the colour picker
            CCControlColourPicker colourPicker = new CCControlColourPicker();
            colourPicker.Color = new CCColor3B(37, 46, 252);
            colourPicker.Position = new CCPoint(colourPicker.ContentSize.Width / 2, 0);

            // Add it to the layer
            layer.AddChild(colourPicker);

            // Add the target-action pair
            colourPicker.AddTargetWithActionForControlEvents(this, ColourValueChanged,
                                                              CCControlEvent.ValueChanged);


            layer_width += colourPicker.ContentSize.Width;

            // Add the black background for the text
            CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground.png");
            background.ContentSize = new CCSize(150, 50);
            background.Position = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0);
            layer.AddChild(background);

            layer_width += background.ContentSize.Width;

            _colorLabel = new CCLabelTtf("#color", "Arial", 26);

            _colorLabel.Position = background.Position;
            layer.AddChild(_colorLabel);

            // Set the layer size
            layer.ContentSize = new CCSize(layer_width, 0);
            layer.AnchorPoint = new CCPoint(0.5f, 0.5f);

            // Update the color text
            ColourValueChanged(colourPicker, CCControlEvent.ValueChanged);
        }
コード例 #41
0
 private void DrawBoard(CCNode gameLayer, Game game)
 {
     game.Board.SetSize(this.tileMap.ContentSize.Width);
     foreach (var piece in game.Board.Pieces)
     {
         var cocoPiece = this.pieceBuilder.Build(piece);
         gameLayer.AddChild(cocoPiece, 99);
     }
 }
コード例 #42
0
        public SpriteZVertex()
        {
            //
            // This test tests z-order
            // If you are going to use it is better to use a 3D projection
            //
            // WARNING:
            // The developer is resposible for ordering it's sprites according to it's Z if the sprite has
            // transparent parts.
            //

            m_dir  = 1;
            m_time = 0;

            CCSize s    = CCDirector.SharedDirector.WinSize;
            float  step = s.Width / 12;

            CCNode node = new CCNode();

            // camera uses the center of the image as the pivoting point
            node.ContentSize = (new CCSize(s.Width, s.Height));
            node.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            node.Position    = (new CCPoint(s.Width / 2, s.Height / 2));

            AddChild(node, 0);

            for (int i = 0; i < 5; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121));
                sprite.Position = (new CCPoint((i + 1) * step, s.Height / 2));
                sprite.VertexZ  = (10 + i * 40);
                node.AddChild(sprite, 0);
            }

            for (int i = 5; i < 11; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 0, 85, 121));
                sprite.Position = (new CCPoint((i + 1) * step, s.Height / 2));
                sprite.VertexZ  = 10 + (10 - i) * 40;
                node.AddChild(sprite, 0);
            }

            node.RunAction(new CCOrbitCamera(10, 1, 0, 0, 360, 0, 0));
        }
コード例 #43
0
        public CCControlPotentiometerTest()
        {
            CCSize screenSize = Layer.VisibleBoundsWorldspace.Size;

            var layer = new CCNode();
            layer.Position = new CCPoint(screenSize.Width / 2, screenSize.Height / 2);
            AddChild(layer, 1);

            double layer_width = 0;

            // Add the black background for the text
            CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground.png");
            background.ContentSize = new CCSize(80, 50);
            background.Position = new CCPoint((float) layer_width + background.ContentSize.Width / 2.0f, 0);
            layer.AddChild(background);

            layer_width += background.ContentSize.Width;

            DisplayValueLabel = new CCLabelTtf("", "Arial", 30);

            _displayValueLabel.Position = background.Position;
            layer.AddChild(_displayValueLabel);

            // Add the slider
            var potentiometer = new CCControlPotentiometer("extensions/potentiometerTrack.png"
                                                           ,
                                                           "extensions/potentiometerProgress.png"
                                                           , "extensions/potentiometerButton.png");
            potentiometer.Position = new CCPoint((float) layer_width + 10 + potentiometer.ContentSize.Width / 2, 0);

            // When the value of the slider will change, the given selector will be call
            potentiometer.AddTargetWithActionForControlEvents(this, ValueChanged, CCControlEvent.ValueChanged);

            layer.AddChild(potentiometer);

            layer_width += potentiometer.ContentSize.Width;

            // Set the layer size
            layer.ContentSize = new CCSize((float) layer_width, 0);
            layer.AnchorPoint = new CCPoint(0.5f, 0.5f);

            // Update the value label
            ValueChanged(potentiometer, CCControlEvent.ValueChanged);
        }
コード例 #44
0
        public SpriteChildrenVisibilityIssue665()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

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

            CCNode   aParent;
            CCSprite sprite1, sprite2, sprite3;

            //
            // SpriteBatchNode
            //
            // parents
            aParent          = new CCSpriteBatchNode("animations/grossini", 50);
            aParent.Position = (new CCPoint(s.Width / 3, s.Height / 2));
            AddChild(aParent, 0);

            sprite1          = new CCSprite("grossini_dance_01.png");
            sprite1.Position = (new CCPoint(0, 0));

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

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

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

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

            //
            // Sprite
            //
            aParent          = new CCNode();
            aParent.Position = (new CCPoint(2 * s.Width / 3, s.Height / 2));
            AddChild(aParent, 0);

            sprite1          = new CCSprite("grossini_dance_01.png");
            sprite1.Position = (new CCPoint(0, 0));

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

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

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

            aParent.AddChild(sprite1);
            sprite1.AddChild(sprite2, -2);
            sprite1.AddChild(sprite3, 2);
        }
コード例 #45
0
ファイル: GameLayer.cs プロジェクト: ARMoir/mobile-samples
		public GameLayer ()
		{

			drawNodeRoot = new CCNode ();
			drawNodeRoot.PositionX = 500;
			drawNodeRoot.PositionY = 350;
			this.AddChild (drawNodeRoot);

			CCDrawNode circle;
			circle = new CCDrawNode ();
			circle.DrawSolidCircle (CCPoint.Zero, DefaultCircleRadius, CCColor4B.Red);
			drawNodeRoot.AddChild (circle);

			lineNode = new LineNode ();
			drawNodeRoot.AddChild (lineNode);

			variableLabel = new CCLabel ("Hello", "Arial", 46, CCLabelFormat.SystemFont);
			variableLabel.HorizontalAlignment = CCTextAlignment.Left;
			variableLabel.AnchorPoint = new CCPoint (0, 0);
			variableLabel.PositionX = 48;
			variableLabel.PositionY = 390;
			this.AddChild (variableLabel);


			easingLabel = new CCLabel ("Hello", "Arial", 46, CCLabelFormat.SystemFont);
			easingLabel.HorizontalAlignment = CCTextAlignment.Left;
			easingLabel.AnchorPoint = new CCPoint (0, 0);
			easingLabel.PositionX = 48;
			easingLabel.PositionY = 330;
			this.AddChild (easingLabel);


			inOutLabel = new CCLabel ("Hello", "Arial", 46, CCLabelFormat.SystemFont);
			inOutLabel.HorizontalAlignment = CCTextAlignment.Left;
			inOutLabel.AnchorPoint = new CCPoint (0, 0);
			inOutLabel.PositionX = 48;
			inOutLabel.PositionY = 270;
			this.AddChild (inOutLabel);



			UpdateLabels ();
		}
コード例 #46
0
        public GameLayer()
        {
            drawNodeRoot           = new CCNode();
            drawNodeRoot.PositionX = 500;
            drawNodeRoot.PositionY = 350;
            this.AddChild(drawNodeRoot);

            CCDrawNode circle;

            circle = new CCDrawNode();
            circle.DrawSolidCircle(CCPoint.Zero, 40, CCColor4B.Red);
            drawNodeRoot.AddChild(circle);

            lineNode = new LineNode();
            drawNodeRoot.AddChild(lineNode);

            variableLabel = new CCLabel("Hello", "Arial", 46, CCLabelFormat.SystemFont);
            variableLabel.HorizontalAlignment = CCTextAlignment.Left;
            variableLabel.AnchorPoint         = new CCPoint(0, 0);
            variableLabel.PositionX           = 48;
            variableLabel.PositionY           = 390;
            this.AddChild(variableLabel);


            easingLabel = new CCLabel("Hello", "Arial", 46, CCLabelFormat.SystemFont);
            easingLabel.HorizontalAlignment = CCTextAlignment.Left;
            easingLabel.AnchorPoint         = new CCPoint(0, 0);
            easingLabel.PositionX           = 48;
            easingLabel.PositionY           = 330;
            this.AddChild(easingLabel);


            inOutLabel = new CCLabel("Hello", "Arial", 46, CCLabelFormat.SystemFont);
            inOutLabel.HorizontalAlignment = CCTextAlignment.Left;
            inOutLabel.AnchorPoint         = new CCPoint(0, 0);
            inOutLabel.PositionX           = 48;
            inOutLabel.PositionY           = 270;
            this.AddChild(inOutLabel);



            UpdateLabels();
        }
コード例 #47
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize screenSize = Layer.VisibleBoundsWorldspace.Size;

            var layer = new CCNode();
            layer.Position = screenSize.Center;
            AddChild(layer, 1);

            float layer_width = 0;

            // Add the black background for the text
            CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground.png");
            background.ContentSize = new CCSize(100, 50);
            background.Position = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0);
            layer.AddChild(background);

            DisplayValueLabel = new CCLabel("0", "Arial", 26, CCLabelFormat.SpriteFont);

            DisplayValueLabel.Position = background.Position;
            layer.AddChild(DisplayValueLabel);

            layer_width += background.ContentSize.Width;

            CCControlStepper stepper = MakeControlStepper();
            stepper.Position = new CCPoint(layer_width + 10 + stepper.ContentSize.Width / 2, 0);
            stepper.ValueChanged += Stepper_ValueChanged;
            layer.AddChild(stepper);

            layer_width += stepper.ContentSize.Width;

            // Set the layer size
            layer.ContentSize = new CCSize(layer_width, 0);
            layer.AnchorPoint = CCPoint.AnchorMiddle;

            // Update the value label
            ValueChanged(stepper, CCControlEvent.ValueChanged);

        }
コード例 #48
0
		public override void OnEnter()
		{
            CCRect visibleBounds = Layer.VisibleBoundsWorldspace;

            base.OnEnter();

			bgNode = new CCNode ();
			bgNode.AnchorPoint = CCPoint.AnchorMiddle;
            contentLayer.AddChild (bgNode);
            bgNode.Position = visibleBounds.Center;

			var bg = new CCSprite("Images/background3");
            bg.AnchorPoint = CCPoint.Zero;
            bg.Position = CCPoint.Zero;

            bgNode.ContentSize = bg.ContentSize;

			bgNode.AddChild (bg, 0, EffectAdvanceScene.kTagBackground);

			grossini = new CCSprite("Images/grossinis_sister2");

            bgNode.AddChild (grossini);

            grossini.Position = bg.BoundingBox.Center + new CCPoint(-100.0f, 0.0f);

			var sc = new CCScaleBy(2, 5);
			var sc_back = sc.Reverse();

			tamara = new CCSprite("Images/grossinis_sister1");

            bgNode.AddChild (tamara);
            tamara.Position = bg.BoundingBox.Center + new CCPoint(100.0f, 0.0f);

			var sc2 = new CCScaleBy(2, 5);
			var sc2_back = sc2.Reverse();

            grossini.RepeatForever (sc, sc_back);
			tamara.RepeatForever(sc2, sc2_back);

		}
コード例 #49
0
ファイル: CCControlUtils.cs プロジェクト: KerwinMa/CocosSharp
		public static CCSprite AddSpriteToTargetWithPosAndAnchor(string spriteName, CCNode target, CCPoint pos, CCPoint anchor)
		{
			var sprite = new CCSprite(spriteName);
    
			if (sprite == null)
				return null;

			sprite.Position = pos;
			sprite.AnchorPoint = anchor;
			target.AddChild(sprite);

			return sprite;
		}
コード例 #50
0
        public CCControlStepperTest()
        {
            CCSize screenSize = Layer.VisibleBoundsWorldspace.Size;

            var layer = new CCNode();
            layer.Position = screenSize.Center;
            AddChild(layer, 1);

            float layer_width = 0;

            // Add the black background for the text
            CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground.png");
            background.ContentSize = new CCSize(100, 50);
            background.Position = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0);
            layer.AddChild(background);

            DisplayValueLabel = new CCLabelTtf("0", "Arial", 26);

            _displayValueLabel.Position = background.Position;
            layer.AddChild(_displayValueLabel);

            layer_width += background.ContentSize.Width;

            CCControlStepper stepper = MakeControlStepper();
            stepper.Position = new CCPoint(layer_width + 10 + stepper.ContentSize.Width / 2, 0);
            stepper.AddTargetWithActionForControlEvents(this, ValueChanged,
                                                        CCControlEvent.ValueChanged);
            layer.AddChild(stepper);

            layer_width += stepper.ContentSize.Width;

            // Set the layer size
            layer.ContentSize = new CCSize(layer_width, 0);
            layer.AnchorPoint = new CCPoint(0.5f, 0.5f);

            // Update the value label
            ValueChanged(stepper, CCControlEvent.ValueChanged);
        }
コード例 #51
0
        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);
        }
コード例 #52
0
        public SpriteChildrenChildren()
        {
            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 CCNode();
            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");
            l2a.AddChild(l3a1);

            // child left top
            l3a2 = new CCSprite("child1.gif");
            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.FlipY = true;
            l2b.AddChild(l3b2);
        }
コード例 #53
0
ファイル: MotionStreakTest1.cs プロジェクト: h7ing/CocosSharp
        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);
        }
コード例 #54
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            contentLayer = new CCLayer();
            Window.IsUseDepthTesting = true;
            node = new CCNode(Layer.VisibleBoundsWorldspace.Size);
            node.AnchorPoint = CCPoint.AnchorMiddle;
            node.IgnoreAnchorPointForPosition = true;

            AddChild(contentLayer);
            contentLayer.AddChild(node);

            CCSize layerSize = contentLayer.VisibleBoundsWorldspace.Size;

            float step = layerSize.Width / 12;

            // 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);
            node.AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);

            sprites = new CCSprite[numOfSprites];

            for (int i = 0; i < 5; i++)
            {
                sprites[i] = new CCSprite(batch.Texture, new CCRect(85 * 0, 121 * 1, 85, 121));
                sprites[i].Position = (new CCPoint((i + 1) * step, layerSize.Height / 2));
                sprites[i].VertexZ = (10 + i * 20);
                batch.AddChild(sprites[i], 0);
            }

            for (int i = 5; i < 11; i++)
            {
                sprites[i] = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 0, 85, 121));
                sprites[i].Position = (new CCPoint((i + 1) * step, layerSize.Height / 2));
                sprites[i].VertexZ = 10 + (10 - i) * 20;
                batch.AddChild(sprites[i], 0);
            }

            // camera uses the center of the image as the pivoting point
            node.RunAction(new CCOrbitCamera(10, 1, 0, 0, 360, 0, 0));
        }
コード例 #55
0
        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);

        }
コード例 #56
0
ファイル: SpriteHybrid.cs プロジェクト: KerwinMa/CocosSharp
        public SpriteHybrid()
        {
            // parents
            CCNode parent1 = new CCNode();
            CCSpriteBatchNode parent2 = new CCSpriteBatchNode("animations/grossini", 50);

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

            sprites = new CCSprite[numOfSprites];

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

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

            usingSpriteBatchNode = false;
        }
コード例 #57
0
ファイル: GameLayer.cs プロジェクト: AGRocks/chezzles
 private void DrawBoard(CCNode gameLayer, Game game)
 {
     game.Board.SetSize(this.tileMap.ContentSize.Width);
     foreach (var piece in game.Board.Pieces)
     {
         var cocoPiece = this.pieceBuilder.Build(piece);
         gameLayer.AddChild(cocoPiece, 99);
     }
 }
コード例 #58
0
        /// <summary>
        /// Initializes a player on a initial position inside a container
        /// </summary>
        /// <param name="player">Instanciated player</param>
        /// <param name="container">Container when will be dropped</param>
        /// <param name="initialPosition">Player initial position</param>
        public virtual CSKPlayer InitializePlayer(CSKPlayer player, CCNode container, CCPoint initialPosition)
        {
            if (Players.Exists((p) => p == player))
            {
                Console.WriteLine("CANNOT ADD PLAYER. ITS ON LAYER");
                return null;
            }

            CCGameSettingsBase.Instance.Player1 = player.klass; //TODO: ARRAY DE PLAYERS

            player.desiredPosition = player.Position;
            player.idle();

            Players.Add(player); //Add to players array

            Player = player;

            container.AddChild(player);

            //AddChild(player, (int)eTAG_DEPTH.PLAYER_LAYER);

            player.Position = initialPosition;

            Console.WriteLine("PLAYER 1 ADDED TO SHIP LAYER");
            return player;
        }
コード例 #59
0
        /// <summary>
        /// Initializes an enemy on a position. This method can be override to add more functionality
        /// </summary>
        /// <param name="enemy">Initialized enemy</param>
        /// <param name="container">Container when will be added</param>
        /// <param name="initialPosition">Position inside the layer</param>
        public virtual CSKEnemy InitializeEnemy(CSKEnemy enemy, CCNode container, CCPoint initialPosition)
        {
            enemy.Position = initialPosition;
            enemy.ScaleX = -1;
            enemy.actionState = ActionState.Idle;

            enemy.desiredPosition = enemy.Position;
            enemy.idle();

            container.AddChild(enemy);
            Enemies.Add(enemy);
            return enemy;
        }