Esempio n. 1
0
        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 SpriteBatchNodeReorderIssue767()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            string   scope = CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/ghosts.plist", "animations/ghosts");
            CCNode   aParent;
            CCSprite l1, l2a, l2b, l3a1, l3a2, l3b1, l3b2;

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

            // parent
            l1          = new CCSprite(scope + "father.gif");
            l1.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            aParent.AddChild(l1, 0, (int)kTagSprite.kTagSprite2);
            CCSize l1Size = l1.ContentSize;

            // child left
            l2a          = new CCSprite(scope + "sister1.gif");
            l2a.Position = (new CCPoint(-25 + l1Size.Width / 2, 0 + l1Size.Height / 2));
            l1.AddChild(l2a, -1, (int)kTags.kTagSpriteLeft);
            CCSize l2aSize = l2a.ContentSize;


            // child right
            l2b          = new CCSprite(scope + "sister2.gif");
            l2b.Position = (new CCPoint(+25 + l1Size.Width / 2, 0 + l1Size.Height / 2));
            l1.AddChild(l2b, 1, (int)kTags.kTagSpriteRight);
            CCSize l2bSize = l2a.ContentSize;


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

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

            // child right bottom
            l3b1          = new CCSprite(scope + "child1.gif");
            l3b1.Scale    = (0.65f);
            l3b1.Position = (new CCPoint(0 + l2bSize.Width / 2, -50 + l2bSize.Height / 2));
            l2b.AddChild(l3b1, -1);

            // child right top
            l3b2          = new CCSprite(scope + "child1.gif");
            l3b2.Scale    = (0.65f);
            l3b2.Position = (new CCPoint(0 + l2bSize.Width / 2, +50 + l2bSize.Height / 2));
            l2b.AddChild(l3b2, 1);

            Schedule(reorderSprites, 1);
        }
        public SpriteChildrenVisibility()
        {
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/grossini.plist");

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

            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);
        }
        public override void OnEnter()
        {
            base.OnEnter();

            float x, y;

            CCSize size = CCDirector.SharedDirector.WinSize;

            x = size.Width;
            y = size.Height;

            CCSprite bg = new CCSprite("Images/background3");

            AddChild(bg, 0, EffectAdvanceScene.kTagBackground);
            bg.Position = new CCPoint(x / 2, y / 2);

            grossini = new CCSprite("Images/grossinis_sister2");
            bg.AddChild(grossini, 1, EffectAdvanceScene.kTagSprite1);
            grossini.Position = new CCPoint(x / 3.0f, 200);
            CCActionInterval   sc      = new CCScaleBy(2, 5);
            CCFiniteTimeAction sc_back = sc.Reverse();

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

            tamara = new CCSprite("Images/grossinis_sister1");
            bg.AddChild(tamara, 1, EffectAdvanceScene.kTagSprite2);
            tamara.Position = new CCPoint(2 * x / 3.0f, 200);
            CCActionInterval   sc2      = new CCScaleBy(2, 5);
            CCFiniteTimeAction sc2_back = sc2.Reverse();

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

            CCLabelTTF label = new CCLabelTTF(title(), "arial", 28);

            label.Position = new CCPoint(x / 2, y - 80);
            AddChild(label);
            label.Tag = EffectAdvanceScene.kTagLabel;

            string strSubtitle = subtitle();

            if (strSubtitle != null)
            {
                CCLabelTTF l = new CCLabelTTF(strSubtitle, "arial", 16);
                AddChild(l, 101);
                l.Position = new CCPoint(size.Width / 2, size.Height - 80);
            }

            CCMenuItemImage item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback);

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

            menu.Position  = new CCPoint(0, 0);
            item1.Position = new CCPoint(size.Width / 2 - 100, 30);
            item2.Position = new CCPoint(size.Width / 2, 30);
            item3.Position = new CCPoint(size.Width / 2 + 100, 30);

            AddChild(menu, 1);
        }
        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);
        }
        public SpriteBatchNodeChildrenChildren()
        {
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/ghosts.plist");

            var rot = new CCRotateBy(10, 360);

            seq = new CCRepeatForever(rot);

            var rot_back = rot.Reverse();

            rot_back_fe = new CCRepeatForever(rot_back);

            // SpriteBatchNode: 3 levels of children

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

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


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

            l1.AddChild(l2a);

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

            l1.AddChild(l2b);


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

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

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

            // child right top
            l3b2       = new CCSprite("child1.gif");
            l3b2.Scale = 0.45f;
            l3b2.FlipY = true;
            l2b.AddChild(l3b2);
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
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;
        }
        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. 11
0
        public CameraOrbitTest()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCSprite p = new CCSprite(TestResource.s_back3);

            AddChild(p, 0);
            p.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            p.Opacity  = 128;

            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;
        }
Esempio n. 12
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSprite bg = new CCSprite("Images/background3");

            AddChild(bg, 0, EffectAdvanceScene.kTagBackground);
            bg.Position = CCVisibleRect.Center;

            grossini = new CCSprite("Images/grossinis_sister2");
            bg.AddChild(grossini, 1, EffectAdvanceScene.kTagSprite1);
            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((CCActionInterval)(new CCSequence(sc, sc_back))));

            tamara = new CCSprite("Images/grossinis_sister1");
            bg.AddChild(tamara, 1, EffectAdvanceScene.kTagSprite2);
            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((CCActionInterval)(new CCSequence(sc2, sc2_back))));

            CCLabelTTF label = new CCLabelTTF(title(), "arial", 28);

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

            CCMenuItemImage item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback);

            CCMenu 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);
        }
Esempio n. 13
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. 14
0
        public Square(string fileName, bool isTouchEnabled, SelectedColor color, PositionInGame position) : base()
        {
            _sprite = new CCSprite(fileName);
            //_square.AnchorPoint = point;

            _sprite.ContentSize = new CCSize(200, 200);
            ColorType           = color;
            CurrentPosition     = position;

            AddChild(_sprite);


            if (isTouchEnabled)
            {
                IsTouchEnabled = isTouchEnabled;
                var touchListener = new CCEventListenerTouchAllAtOnce();
                touchListener.OnTouchesBegan = OnTouchesBegan;

                AddEventListener(touchListener, this);
            }
            else //signal squares
            {
                //TODO: add +1 to square _sprite.AddChild
                _plusOneLabel          = new CCLabel("+1", "Fonts/arial", 36, CCLabelFormat.SpriteFont);
                _plusOneLabel.Position = new CCPoint(100, 100);
                _plusOneLabel.Visible  = false;
                _sprite.AddChild(_plusOneLabel, 1);
            }
        }
Esempio n. 15
0
        public NodeToWorld()
        {
            //
            // This code tests that nodeToParent works OK:
            //  - It tests different anchor Points
            //  - It tests different children anchor points

            CCSprite back = new CCSprite(TestResource.s_back3);

            AddChild(back, -10);
            back.AnchorPoint = (new CCPoint(0, 0));
            CCSize backSize = back.ContentSize;

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

            menu.AlignItemsVertically();
            menu.Position = (new CCPoint(backSize.Width / 2, backSize.Height / 2));
            back.AddChild(menu);

            CCActionInterval rot = new CCRotateBy(5, 360);
            CCAction         fe  = new CCRepeatForever(rot);

            item.RunAction(fe);

            CCActionInterval move  = new CCMoveBy(3, new CCPoint(200, 0));
            var move_back          = (CCActionInterval)move.Reverse();
            CCFiniteTimeAction seq = CCSequence.FromActions(move, move_back);
            CCAction           fe2 = new CCRepeatForever((CCActionInterval)seq);

            back.RunAction(fe2);
        }
Esempio n. 16
0
        void AddStopwatch()
        {
            CCLabel stopwatchLabel;
            CCLabel previousBestTimeLabel;

            stopwatchSprite                    = new CCSprite("StopwatchBackground");
            stopwatchSprite.Color              = CCColor3B.Gray;
            stopwatchSprite.PositionX          = layerWidth - 44;
            stopwatchSprite.PositionY          = layerHeight - 18;
            stopwatchSprite.ContentSize        = new CCSize(80, 30);
            stopwatchSprite.UserData           = 0;
            previousBestTimeSprite             = new CCSprite("StopwatchBackground");
            previousBestTimeSprite.Color       = CCColor3B.White;
            previousBestTimeSprite.PositionX   = layerWidth - 44;
            previousBestTimeSprite.PositionY   = layerHeight - 51;
            previousBestTimeSprite.ContentSize = new CCSize(80, 30);
            stopwatchLabel                 = new CCLabel(string.Empty, "JosefinSans.ttf", 30, CCLabelFormat.SystemFont);
            stopwatchLabel.Tag             = 1;
            stopwatchLabel.Text            = "00:00:00";
            stopwatchLabel.Color           = CCColor3B.White;
            stopwatchLabel.Position        = new CCPoint(stopwatchSprite.ContentSize.Width / 2, stopwatchSprite.ContentSize.Height / 2);
            previousBestTimeLabel          = new CCLabel(string.Empty, "JosefinSans.ttf", 30, CCLabelFormat.SystemFont);
            previousBestTimeLabel.Tag      = 1;
            previousBestTimeLabel.Text     = (String.IsNullOrWhiteSpace(GetDefault(PREVIOUS_BEST_TIME_KEY)) == true ? "00:00:00" : GetDefault(PREVIOUS_BEST_TIME_KEY));
            previousBestTimeLabel.Color    = CCColor3B.Gray;
            previousBestTimeLabel.Position = new CCPoint(stopwatchSprite.ContentSize.Width / 2, stopwatchSprite.ContentSize.Height / 2);

            stopwatchSprite.AddChild(stopwatchLabel);
            previousBestTimeSprite.AddChild(previousBestTimeLabel);
            AddChild(stopwatchSprite);
            AddChild(previousBestTimeSprite);
        }
Esempio n. 17
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. 18
0
        /// <summary>
        /// Иговой цикл на экране с меню - падающие крисстальчики на фоне
        /// </summary>
        private void UpdateGems()
        {
            if (CCRandom.NextDouble() < 0.02)
            {
                var type   = CCRandom.GetRandomInt(0, 4);
                var sprite = new CCSprite("crystalscrystals/" + type + ".png");
                var x      = CCRandom.NextDouble() * CCDirector.SharedDirector.WinSize.Width + Constants.KGemSize / 2;
                var y      = CCDirector.SharedDirector.WinSize.Height + Constants.KGemSize / 2;
                var scale  = 0.2 + 0.8 * CCRandom.NextDouble();
                var speed  = 2 * scale * Constants.KGemSize / 40;
                sprite.Position = new CCPoint((float)x, (float)y);
                sprite.Scale    = (float)scale;
                _fallingGems.Add(sprite, (float)speed);
                _background.AddChild(sprite);
            }

            var gems = _fallingGems.Keys.ToArray();

            foreach (var gem in gems)
            {
                var speed = _fallingGems[gem];
                var pos   = gem.Position;
                gem.Position = pos - new CCPoint(0, speed);
                if (pos.Y < -Constants.KGemSize / 2)
                {
                    _background.RemoveChild(gem, true);
                    _fallingGems.Remove(gem);
                }
            }
        }
Esempio n. 19
0
        public Test6()
        {
            CCSprite sp1  = new CCSprite(TestResource.s_pPathSister1);
            CCSprite sp11 = new CCSprite(TestResource.s_pPathSister1);

            CCSprite sp2  = new CCSprite(TestResource.s_pPathSister2);
            CCSprite sp21 = new CCSprite(TestResource.s_pPathSister2);

            sp1.Position = (new CCPoint(100, 160));
            sp2.Position = (new CCPoint(380, 160));

            CCActionInterval rot = new CCRotateBy(2, 360);
            var      rot_back    = rot.Reverse() as CCActionInterval;
            CCAction forever1    = new CCRepeatForever((CCActionInterval)CCSequence.FromActions(rot, rot_back));
            var      forever11   = (CCAction)(forever1.Copy());

            var forever2  = (CCAction)(forever1.Copy());
            var forever21 = (CCAction)(forever1.Copy());

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

            sp1.RunAction(forever1);
            sp11.RunAction(forever11);
            sp2.RunAction(forever2);
            sp21.RunAction(forever21);

            Schedule(addAndRemove, 2.0f);
        }
Esempio n. 20
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);
        }
        public CCSprite MakeIconBase64(string base64string, string iconSpeechText, float positionX, float positionY, float scale, float textScale, bool textVisible)
        {
            scale = (scale == -1) ? 1 : scale;

            var parentSprite = new CCSprite("BlankFrame")
            {
                PositionX   = positionX,
                PositionY   = positionY,
                ContentSize = new CCSize(dimension, dimension),
                Scale       = scale,
                Tag         = SpriteTypes.IconTag
            };

            byte[] bytes       = System.Convert.FromBase64String(base64string);
            var    testTexture = new CCTexture2D(bytes);
            var    testFrame   = new CCSpriteFrame(testTexture, new CCRect(0, 0, testTexture.PixelsWide, testTexture.PixelsHigh));

            var dimToScale = System.Math.Max(testFrame.ContentSize.Width, testFrame.ContentSize.Height);
            var scalingImg = (parentSprite.ContentSize.Height * 0.75f) / dimToScale;

            var subIconFrame = new CCSprite(testFrame)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                ContentSize = new CCSize(testFrame.ContentSize.Width * scalingImg, testFrame.ContentSize.Height * scalingImg),
                PositionX   = parentSprite.ContentSize.Width / 2f,
                PositionY   = parentSprite.ContentSize.Height / 2f + parentSprite.ContentSize.Height * 0.075f,
                Tag         = SpriteTypes.ImageTag
            };

            var label = new CCLabel(iconSpeechText, "Arial", 18, CCLabelFormat.SystemFont)
            {
                Color               = CCColor3B.Black,
                AnchorPoint         = CCPoint.AnchorMiddle,
                HorizontalAlignment = CCTextAlignment.Center,
                VerticalAlignment   = CCVerticalTextAlignment.Center,
                ContentSize         = new CCSize(parentSprite.ContentSize.Width, parentSprite.ContentSize.Height * 0.25f),
                Position            = new CCPoint(parentSprite.ContentSize.Width / 2, parentSprite.ContentSize.Height * 0.1f),
                Scale               = textScale,
                Visible             = textVisible,
                Tag = SpriteTypes.ContentTag
            };

            parentSprite.AddChild(subIconFrame);
            parentSprite.AddChild(label);

            return(parentSprite);
        }
Esempio n. 22
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();
        }
Esempio n. 23
0
        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. 24
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);
        }
        public CCSprite MakeAddButton()
        {
            var parentSprite = new CCSprite("BlankFrame")
            {
                Tag = SpriteTypes.AddTag
            };

            var scaling = (DynamicWidth * 0.1f) / parentSprite.ContentSize.Width;

            parentSprite.ContentSize = new CCSize(parentSprite.ContentSize.Width * scaling, parentSprite.ContentSize.Height * scaling);

            parentSprite.PositionX = DynamicWidth - (parentSprite.ContentSize.Width / 2) - padding;
            parentSprite.PositionY = (parentSprite.ContentSize.Height / 2) + padding;

            var subIconFrame = new CCSprite("AddNew")
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                ContentSize = new CCSize(parentSprite.ContentSize.Width * 0.5f, parentSprite.ContentSize.Height * 0.5f)
            };

            subIconFrame.PositionX = parentSprite.ContentSize.Width - (subIconFrame.ContentSize.Width);
            subIconFrame.PositionY = parentSprite.ContentSize.Height - (subIconFrame.ContentSize.Height);

            var label = new CCLabel("Add Icon", "Arial", 18, CCLabelFormat.SystemFont)
            {
                Color               = CCColor3B.Black,
                AnchorPoint         = CCPoint.AnchorMiddle,
                HorizontalAlignment = CCTextAlignment.Center,
                VerticalAlignment   = CCVerticalTextAlignment.Center,
                ContentSize         = new CCSize(parentSprite.ContentSize.Width, parentSprite.ContentSize.Height * 0.25f),
                Position            = new CCPoint(parentSprite.ContentSize.Width / 2, parentSprite.ContentSize.Height / 6),
                Tag = SpriteTypes.ContentTag
            };

            parentSprite.AddChild(subIconFrame);
            parentSprite.AddChild(label);

            return(parentSprite);
        }
Esempio n. 26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Core.Slider"/> class.
        /// </summary>
        /// <param name="mainLayer">Main layer.</param>
        /// <param name="tl">Touch listener.</param>
        /// <param name="textureBar">Texture of the slider bar.</param>
        /// <param name="texturePoint">Texture of the slider point.</param>
        /// <param name="position">Position of the slider.</param>
        /// <param name="winSize">Window size.</param>
        /// <param name="min">Minimum value of the slider.</param>
        /// <param name="max">Maximum value of the slider.</param>
        /// <param name="rot">Rotation of the slider sprite (default -90).</param>
        /// <param name="scale">Scale of the slider sprite (default 0.8f).</param>
        internal CCSlider(CCLayer mainLayer, TouchList tl, string textureBar, string texturePoint, CCPoint position, CCSize winSize, int min, int max, float rot = -90, float scale = 0.8f)
        {
            //Defining the sprite
            spriteBar             = new CCSprite(textureBar);
            spriteBar.AnchorPoint = new CCPoint(0, 0.5f);
            spriteBar.Position    = position;
            spriteBar.Rotation    = rot;
            spriteBar.Scale       = scale;
            spriteBar.BlendFunc   = CCBlendFunc.AlphaBlend;
            mainLayer.AddChild(spriteBar);

            spritePoint = new CCSprite(texturePoint);
            spriteBar.AddChild(spritePoint);
            spritePoint.Position  = new CCPoint(0, spriteBar.ContentSize.Height / 2);
            spritePoint.Scale     = scale * 0.4f;
            spritePoint.BlendFunc = CCBlendFunc.AlphaBlend;

            _min = min;
            _max = max;

            _currentValue = _min;


            lblValue          = new CCLabel(_currentValue.ToString(), "Arial", 65 * scale);
            lblValue.Position = new CCPoint(spriteBar.ContentSize.Width / 2, -0.05f * spriteBar.ContentSize.Height);
            spriteBar.AddChild(lblValue);

            this.winSize   = winSize;
            this.mainLayer = mainLayer;



            this.scale = scale;

            //Defining the event variables
            touch = tl;
            touch.eventTouchBegan += touchBegan;
            touch.eventTouchMoved += touchMoved;
        }
        public CCSprite MakeFolder(string assetName, string folderName, float positionX, float positionY, float scale)
        {
            var parentSprite = new CCSprite("BlankFrame");

            parentSprite.PositionX = positionX;
            parentSprite.PositionY = positionY;

            var scaling = (DynamicWidth * 0.1f) / parentSprite.ContentSize.Width;

            parentSprite.ContentSize = new CCSize(parentSprite.ContentSize.Width * scaling, parentSprite.ContentSize.Height * scaling);

            parentSprite.Scale = scale;
            parentSprite.Tag   = SpriteTypes.FolderTag;

            var subIconFrame = new CCSprite(assetName)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                ContentSize = new CCSize(parentSprite.ContentSize.Width * 0.9f, parentSprite.ContentSize.Height * 0.9f),
                PositionX   = parentSprite.ContentSize.Width / 2,
                PositionY   = parentSprite.ContentSize.Height / 2,
            };

            var label = new CCLabel(folderName, "Arial", 18, CCLabelFormat.SystemFont)
            {
                Color               = CCColor3B.White,
                AnchorPoint         = CCPoint.AnchorMiddle,
                HorizontalAlignment = CCTextAlignment.Center,
                VerticalAlignment   = CCVerticalTextAlignment.Center,
                ContentSize         = new CCSize(parentSprite.ContentSize.Width, parentSprite.ContentSize.Height * 0.25f),
                Position            = new CCPoint(parentSprite.ContentSize.Width / 2, parentSprite.ContentSize.Height / 3),
                Tag = SpriteTypes.ContentTag
            };

            parentSprite.AddChild(subIconFrame);
            parentSprite.AddChild(label);

            return(parentSprite);
        }
Esempio n. 28
0
        public MainScene(CCGameView gameView) : base(gameView)
        {
            var layer = new CCLayerColor(CCColor4B.Transparent);

            this.AddLayer(layer);
            _background = new CCSprite("Images/Background/bg.png");
            _logo       = new CCSprite("Images/Sprites/logo_tokblitz.png");
            _logo.setSizeLogoLarge();
            _logo.Position          = new CCPoint(App.ScreenWidth / 2, App.ScreenHeight / 2);
            _background.ContentSize = CustomSize.FullScreen;
            _background.Position    = new CCPoint(App.ScreenWidth / 2, App.ScreenHeight / 2);
            layer.AddChild(_background);
            _background.AddChild(_logo);
        }
        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. 30
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = CCDirector.SharedDirector.WinSize;

            CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1);
            CCSprite sp2 = new CCSprite(TestResource.s_pPathSister2);
            CCSprite sp3 = new CCSprite(TestResource.s_pPathSister1);
            CCSprite 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);

            CCActionInterval a1 = new CCRotateBy(2, 360);
            CCActionInterval a2 = new CCScaleBy(2, 2);

            CCAction action1 = new CCRepeatForever((CCActionInterval) new CCSequence(a1, a2, a2.Reverse())
                                                   );
            CCAction action2 = new CCRepeatForever((CCActionInterval)
                                                   (new CCSequence(
                                                        (CCActionInterval)(a1.Copy()),
                                                        (CCActionInterval)(a2.Copy()),
                                                        a2.Reverse()))
                                                   );

            sp2.AnchorPoint = (new CCPoint(0, 0));

            sp1.RunAction(action1);
            sp2.RunAction(action2);
        }