예제 #1
0
        public override void OnEnter()
        {
            base.OnEnter();

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

            // cleanup
            CCNode bg = GetChildByTag(EffectAdvanceScene.kTagBackground);
            RemoveChild(bg, true);

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

            // foreground
            CCLayerColor layer2 = new CCLayerColor(new CCColor4B(0, 255, 0, 255));
            CCSprite 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(layer2, 1);

            layer2.RunAction(new CCRepeatForever (effect));
        }
예제 #2
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLabelTTF label = new CCLabelTTF(title(), "arial", 18);
            AddChild(label, 1);
            label.Position = new CCPoint(s.Width / 2, s.Height - 50);

            string strSubtitle = subtitle();
            if (strSubtitle != null)
            {
                CCLabelTTF l = new CCLabelTTF(strSubtitle, "arial", 22);
                AddChild(l, 1);
                l.Position = new CCPoint(s.Width / 2, s.Height - 80);
            }

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

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

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

            AddChild(menu, 1);

            CCLayerColor background = new CCLayerColor(new CCColor4B(255,0,0,255));
            AddChild(background, -10);
        }
예제 #3
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = CCDirector.SharedDirector.WinSize;
            CCLayerColor layer1 = new CCLayerColor(new CCColor4B(255, 255, 0, 80), 100, 300);
            layer1.Position = (new CCPoint(s.Width / 3, s.Height / 2));
            layer1.IgnoreAnchorPointForPosition = false;
            AddChild(layer1, 1);

            CCLayerColor layer2 = new CCLayerColor(new CCColor4B(0, 0, 255, 255), 100, 300);
            layer2.Position = (new CCPoint((s.Width / 3) * 2, s.Height / 2));
            layer2.IgnoreAnchorPointForPosition = false;
            AddChild(layer2, 1);

            CCActionInterval actionTint = new CCTintBy (2, -255, -127, 0);
            CCActionInterval actionTintBack = (CCActionInterval)actionTint.Reverse();
            CCActionInterval seq1 = (CCActionInterval)CCSequence.FromActions(actionTint, actionTintBack);
            layer1.RunAction(seq1);

            CCActionInterval actionFade = new CCFadeOut  (2.0f);
            CCActionInterval actionFadeBack = (CCActionInterval)actionFade.Reverse();
            CCActionInterval seq2 = (CCActionInterval)CCSequence.FromActions(actionFade, actionFadeBack);
            layer2.RunAction(seq2);
        }
예제 #4
0
        public override bool Init()
        {
            if (base.Init())
            {
                CCSize s = CCDirector.SharedDirector.WinSize;

                CCLayerColor background = new CCLayerColor(new CCColor4B(255, 0, 255, 255));
                AddChild(background);

                CCLayerColor sprite_a = new CCLayerColor(new CCColor4B(255, 0, 0, 255), 700, 700);
                sprite_a.AnchorPoint = new CCPoint(0.5f, 0.5f);
                sprite_a.IgnoreAnchorPointForPosition = true;
                sprite_a.Position = new CCPoint(0.0f, s.Height / 2);
                AddChild(sprite_a);

                sprite_a.RunAction(new CCRepeatForever ((CCActionInterval)new CCSequence(
                                                                       new CCMoveTo (1.0f, new CCPoint(1024.0f, 384.0f)),
                                                                       new CCMoveTo (1.0f, new CCPoint(0.0f, 384.0f)))));

                CCLayerColor sprite_b = new CCLayerColor(new CCColor4B(0, 0, 255, 255), 400, 400);
                sprite_b.AnchorPoint = new CCPoint(0.5f, 0.5f);
                sprite_b.IgnoreAnchorPointForPosition = true;
                sprite_b.Position = new CCPoint(s.Width / 2, s.Height / 2);
                AddChild(sprite_b);

                CCMenuItemLabel label = new CCMenuItemLabel(new CCLabelTTF("Flip Me", "Helvetica", 24), callBack);
                CCMenu menu = new CCMenu(label);
                menu.Position = new CCPoint(s.Width - 200.0f, 50.0f);
                AddChild(menu);

                return true;
            }

            return false;
        }
예제 #5
0
        public override bool Init()
        {
            if (base.Init())
            {
                // ask director the the window size
                CCSize size = CCDirector.SharedDirector.WinSize;

                QuestionContainerSprite question = new QuestionContainerSprite();
                QuestionContainerSprite question2 = new QuestionContainerSprite();
                question.Init();
                question2.Init();

                //		[question setContentSize:CGSizeMake(50,50)];
                //		[question2 setContentSize:CGSizeMake(50,50)];

                CCMenuItemSprite sprite = new CCMenuItemSprite(question2, question, this, selectAnswer);
                CCLayerColor layer = new CCLayerColor(new CCColor4B(0, 0, 255, 255), 100, 100);


                CCLayerColor layer2 = new CCLayerColor(new CCColor4B(255, 0, 0, 255), 100, 100);
                CCMenuItemSprite sprite2 = new CCMenuItemSprite(layer, layer2, this, selectAnswer);
                CCMenu menu = new CCMenu(sprite, sprite2, null);
                menu.AlignItemsVerticallyWithPadding(100);
                menu.Position = new CCPoint(size.Width / 2, size.Height / 2);

                // add the label as a child to this Layer
                AddChild(menu);

                return true;
            }
            return false;
        }
예제 #6
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = CCDirector.SharedDirector.WinSize;

            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("zwoptex/grossini.plist");
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("zwoptex/grossini-generic.plist");

            CCLayerColor layer1 = new CCLayerColor(new CCColor4B(255, 0, 0, 255), 85, 121);
            layer1.Position = new CCPoint(s.Width / 2 - 80 - (85.0f * 0.5f), s.Height / 2 - (121.0f * 0.5f));
            AddChild(layer1);

            sprite1 = new CCSprite(CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName("grossini_dance_01.png"));
            sprite1.Position = (new CCPoint(s.Width / 2 - 80, s.Height / 2));
            AddChild(sprite1);

            sprite1.FlipX = false;
            sprite1.FlipY = false;

            CCLayerColor layer2 = new CCLayerColor(new CCColor4B(255, 0, 0, 255), 85, 121);
            layer2.Position = new CCPoint(s.Width / 2 + 80 - (85.0f * 0.5f), s.Height / 2 - (121.0f * 0.5f));
            AddChild(layer2);

            sprite2 = new CCSprite(CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName("grossini_dance_generic_01.png"));
            sprite2.Position = (new CCPoint(s.Width / 2 + 80, s.Height / 2));
            AddChild(sprite2);

            sprite2.FlipX = false;
            sprite2.FlipY = false;

            Schedule(startIn05Secs, 1.0f);

            counter = 0;
        }
예제 #7
0
        public override void OnEnter()
        {
            base.OnEnter();

            this.TouchEnabled = true;

            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLayerColor layer1 = new CCLayerColor(new CCColor4B(0xFF, 0xFF, 0x00, 0x80), s.Width * 0.75f, s.Height * 0.75f);
            layer1.IgnoreAnchorPointForPosition = false;
            layer1.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            layer1.ChildClippingMode = CCClipMode.Bounds;
            AddChild(layer1, 1);

            s = layer1.ContentSize;

            m_pInnerLayer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80), s.Width * 0.5f, s.Height * 0.5f);
            m_pInnerLayer.IgnoreAnchorPointForPosition = false;
            m_pInnerLayer.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            m_pInnerLayer.ChildClippingMode = CCClipMode.Bounds;
            
            layer1.AddChild(m_pInnerLayer, 1);
            
            //
            // Add two labels using BM label class
            // CCLabelBMFont
            CCLabelBMFont label1 = new CCLabelBMFont("LABEL1", "fonts/konqa32.fnt");
            label1.Position = new CCPoint(m_pInnerLayer.ContentSize.Width, m_pInnerLayer.ContentSize.Height * 0.75f);
            m_pInnerLayer.AddChild(label1);
            
            CCLabelBMFont label2 = new CCLabelBMFont("LABEL2", "fonts/konqa32.fnt");
            label2.Position = new CCPoint(0, m_pInnerLayer.ContentSize.Height * 0.25f);
            m_pInnerLayer.AddChild(label2);

            float runTime = 12f;

            CCScaleTo scaleTo2 = new CCScaleTo(runTime * 0.25f, 3.0f);
            CCScaleTo scaleTo3 = new CCScaleTo(runTime * 0.25f, 1.0f);

            CCFiniteTimeAction seq = new CCRepeatForever(
                new CCSequence(scaleTo2, scaleTo3)
                );

            m_pInnerLayer.RunAction(seq);

            CCSize size = CCDirector.SharedDirector.WinSize;

            var move1 = new CCMoveTo(2, new CCPoint(size.Width / 2, size.Height));
            var move2 = new CCMoveTo(2, new CCPoint(size.Width, size.Height / 2));
            var move3 = new CCMoveTo(2, new CCPoint(size.Width / 2, 0));
            var move4 = new CCMoveTo(2, new CCPoint(0, size.Height / 2));

            layer1.RunAction(new CCRepeatForever(new CCSequence(move1, move2, move3, move4)));

        }
예제 #8
0
        public LabelGlyphDesigner()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLayerColor layer = new CCLayerColor(new CCColor4B(128, 128, 128, 255));
            AddChild(layer, -10);

            // CCLabelBMFont
            CCLabelBMFont label1 = new CCLabelBMFont("Testing Glyph Designer", "fonts/futura-48.fnt");
            AddChild(label1);
            label1.Position = new CCPoint(s.Width / 2, s.Height / 2);
        }
예제 #9
0
        public override void OnEnter()
        {
            base.OnEnter();

            this.TouchEnabled = true;

            CCSize s = CCDirector.SharedDirector.WinSize;
            CCLayerColor layer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80), 200, 200);

            layer.IgnoreAnchorPointForPosition = false;
            layer.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            AddChild(layer, 1, kTagLayer);
        }
예제 #10
0
        public RenderTextureIssue937()
        {
            /*
            *     1    2
            * A: A1   A2
            *
            * B: B1   B2
            *
            *  A1: premulti sprite
            *  A2: premulti render
            *
            *  B1: non-premulti sprite
            *  B2: non-premulti render
            */
            CCLayerColor background = new CCLayerColor(new CCColor4B(200, 200, 200, 255));
            AddChild(background);

            CCSprite spr_premulti = new CCSprite("Images/fire");
            spr_premulti.Position = new CCPoint(16, 48);

            CCSprite spr_nonpremulti = new CCSprite("Images/fire");
            spr_nonpremulti.Position = new CCPoint(16, 16);


            /* A2 & B2 setup */
            CCRenderTexture rend = new CCRenderTexture(32, 64);

            // It's possible to modify the RenderTexture blending function by
            //CCBlendFunc bf = new CCBlendFunc (OGLES.GL_ONE, OGLES.GL_ONE_MINUS_SRC_ALPHA);
            //rend.Sprite.BlendFunc = bf;

            rend.Begin();
            // A2
            spr_premulti.Visit();
            // B2
            spr_nonpremulti.Visit();
            rend.End();

            CCSize s = CCDirector.SharedDirector.WinSize;

            /* A1: setup */
            spr_premulti.Position = new CCPoint(s.Width / 2 - 16, s.Height / 2 + 16);
            /* B1: setup */
            spr_nonpremulti.Position = new CCPoint(s.Width / 2 - 16, s.Height / 2 - 16);

            rend.Position = new CCPoint(s.Width / 2 + 16, s.Height / 2);

            AddChild(spr_nonpremulti);
            AddChild(spr_premulti);
            AddChild(rend);
        }
예제 #11
0
        public LayerTestBlend()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;
            CCLayerColor layer1 = new CCLayerColor(new CCColor4B(255, 255, 255, 80));

            CCSprite sister1 = new CCSprite(s_pPathSister1);
            CCSprite sister2 = new CCSprite(s_pPathSister2);

            AddChild(sister1);
            AddChild(sister2);
            AddChild(layer1, 100, kTagLayer);

            sister1.Position = new CCPoint(160, s.Height / 2);
            sister2.Position = new CCPoint(320, s.Height / 2);

            Schedule(newBlend, 1.0f);
        }
예제 #12
0
        public Atlas3()
        {
            m_time = 0;

            CCLayerColor col = new CCLayerColor(new CCColor4B(128, 128, 128, 255));
            AddChild(col, -10);

            CCLabelBMFont label1 = new CCLabelBMFont("Test", "fonts/bitmapFontTest2.fnt");

            // testing anchors
            label1.AnchorPoint = new CCPoint(0, 0);
            AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1);
            CCActionInterval fade = new CCFadeOut  (1.0f);
            CCFiniteTimeAction fade_in = fade.Reverse();
            CCFiniteTimeAction seq = CCSequence.FromActions(fade, fade_in);
            CCAction repeat = new CCRepeatForever ((CCActionInterval)seq);
            label1.RunAction(repeat);


            // VERY IMPORTANT
            // color and opacity work OK because bitmapFontAltas2 loads a BMP image (not a PNG image)
            // If you want to use both opacity and color, it is recommended to use NON premultiplied images like BMP images
            // Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected
            CCLabelBMFont label2 = new CCLabelBMFont("Test", "fonts/bitmapFontTest2.fnt");
            // testing anchors
            label2.AnchorPoint = new CCPoint(0.5f, 0.5f);
            label2.Color = ccRED;
            AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);
            label2.RunAction((CCAction)(repeat.Copy()));

            CCLabelBMFont label3 = new CCLabelBMFont("Test", "fonts/bitmapFontTest2.fnt");
            // testing anchors
            label3.AnchorPoint = new CCPoint(1, 1);
            AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3);


            CCSize s = CCDirector.SharedDirector.WinSize;
            label1.Position = new CCPoint();
            label2.Position = new CCPoint(s.Width / 2, s.Height / 2);
            label3.Position = new CCPoint(s.Width, s.Height);

            base.Schedule(step);//:@selector(step:)];
        }
예제 #13
0
        public LabelTTFA8Test()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLayerColor layer = new CCLayerColor(new CCColor4B(128, 128, 128, 255));
            AddChild(layer, -10);

            // CCLabelBMFont
            CCLabelTTF label1 = new CCLabelTTF("Testing A8 Format", "Marker Felt", 38);
            AddChild(label1);
            label1.Color = CCTypes.CCRed;
            label1.Position = new CCPoint(s.Width / 2, s.Height / 2);

            CCFadeOut fadeOut = new CCFadeOut  (2);
            CCFadeIn fadeIn = new CCFadeIn  (2);
            CCFiniteTimeAction seq = new CCSequence(fadeOut, fadeIn);
            CCRepeatForever forever = new CCRepeatForever ((CCActionInterval) seq);
            label1.RunAction(forever);
        }
예제 #14
0
        public MainLayer()
        {
            base.TouchEnabled = true;

            CCSprite sprite = new CCSprite(ClickAndMoveTest.s_pPathGrossini);

            CCLayer layer = new CCLayerColor(new CCColor4B(255, 255, 0, 255));
            AddChild(layer, -1);

            AddChild(sprite, 0, ClickAndMoveTest.kTagSprite);
            sprite.Position = new CCPoint(20, 150);

            sprite.RunAction(new CCJumpTo (4, new CCPoint(300, 48), 100, 4));

            layer.RunAction(new CCRepeatForever (
                                                                (CCActionInterval)(CCSequence.FromActions(
                                                                                    new CCFadeIn  (1),
                                                                                    new CCFadeOut  (1)))
                                                                ));
        }
예제 #15
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCLayerColor l = new CCLayerColor(m_tColor);
            m_pInScene.Visible = false;

            AddChild(l, 2, kSceneFade);
            CCNode f = GetChildByTag(kSceneFade);

            var a = (CCActionInterval) new CCSequence
                                           (
                                               new CCFadeIn (m_fDuration / 2),
                                               new CCCallFunc((HideOutShowIn)),
                                               new CCFadeOut  (m_fDuration / 2),
                                               new CCCallFunc((Finish))
                                           );

            f.RunAction(a);
        }
예제 #16
0
        public override void OnEnter()
        {
            base.OnEnter();

            this.TouchEnabled = true;

            CCSize s = CCDirector.SharedDirector.WinSize;
            CCLayerColor layer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80), s.Width * 0.75f, s.Height * 0.75f);

            layer.IgnoreAnchorPointForPosition = false;
            layer.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            AddChild(layer, 1, kTagLayer);
            //
            // Add two labels using BM label class
            // CCLabelBMFont
            CCLabelBMFont label1 = new CCLabelBMFont("LABEL1", "fonts/konqa32.fnt");
            layer.AddChild(label1);
            label1.Position = new CCPoint(layer.ContentSize.Width / 2, layer.ContentSize.Height * 0.75f);
            CCLabelBMFont label2 = new CCLabelBMFont("LABEL2", "fonts/konqa32.fnt");
            layer.AddChild(label2);
            label2.Position = new CCPoint(layer.ContentSize.Width / 2, layer.ContentSize.Height * 0.25f);
            //
            // Do the sequence of actions in the bug report
            float waitTime = 3f;
            float runTime = 12f;
            layer.Visible = false;
            CCHide hide = new CCHide();
            CCScaleTo scaleTo1 = new CCScaleTo(0.0f, 0.0f);
            CCShow show = new CCShow();
            CCDelayTime delay = new CCDelayTime (waitTime);
            CCScaleTo scaleTo2 = new CCScaleTo(runTime * 0.25f, 1.2f);
            CCScaleTo scaleTo3 = new CCScaleTo(runTime * 0.25f, 0.95f);
            CCScaleTo scaleTo4 = new CCScaleTo(runTime * 0.25f, 1.1f);
            CCScaleTo scaleTo5 = new CCScaleTo(runTime * 0.25f, 1.0f);

            CCFiniteTimeAction seq = new CCSequence(hide, scaleTo1, show, delay, scaleTo2, scaleTo3, scaleTo4, scaleTo5);

            layer.RunAction(seq);


        }
예제 #17
0
        public override void OnEnter()
        {
            base.OnEnter();

            float x, y;

            CCSize size = CCDirector.SharedDirector.WinSize;
            x = size.Width;
            y = size.Height;

            CCNode blue = new CCLayerColor(new CCColor4B(0, 0, 255, 255));
            CCNode red = new CCLayerColor(new CCColor4B(255, 0, 0, 255));
            CCNode green = new CCLayerColor(new CCColor4B(0, 255, 0, 255));
            CCNode white = new CCLayerColor(new CCColor4B(255, 255, 255, 255));

            blue.Scale = (0.5f);
            blue.Position = (new CCPoint(-x / 4, -y / 4));
            blue.AddChild(SpriteLayer.node());

            red.Scale = (0.5f);
            red.Position = (new CCPoint(x / 4, -y / 4));

            green.Scale = (0.5f);
            green.Position = (new CCPoint(-x / 4, y / 4));
            green.AddChild(TestLayer.node());

            white.Scale = (0.5f);
            white.Position = (new CCPoint(x / 4, y / 4));

            AddChild(blue, -1);
            AddChild(white);
            AddChild(green);
            AddChild(red);

            CCAction rot = new CCRotateBy (8, 720);

            blue.RunAction(rot);
            red.RunAction((CCAction)(rot.Copy()));
            green.RunAction((CCAction)(rot.Copy()));
            white.RunAction((CCAction)(rot.Copy()));
        }
예제 #18
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCLayerColor l = new CCLayerColor(m_tColor);

            m_pInScene.Visible = false;

            AddChild(l, 2, kSceneFade);
            CCNode f = GetChildByTag(kSceneFade);

            var a = (CCActionInterval)CCSequence.FromActions
                    (
                new CCFadeIn(m_fDuration / 2),
                new CCCallFunc((HideOutShowIn)),
                new CCFadeOut(m_fDuration / 2),
                new CCCallFunc((Finish))
                    );

            f.RunAction(a);
        }
예제 #19
0
        public override bool Init()
        {
            // always call "super" init
            // Apple recommends to re-assign "self" with the "super" return value
            if (base.Init())
            {
                TouchEnabled = true;
                // ask director the the window size
                CCSize size = CCDirector.SharedDirector.WinSize;
                CCLayerColor layer;
                for (int i = 0; i < 5; i++)
                {
                    layer = new CCLayerColor(new CCColor4B((byte)(i*20), (byte)(i*20), (byte)(i*20),255));
                    layer.ContentSize = new CCSize(i * 100, i * 100);
                    layer.Position = new CCPoint(size.Width / 2, size.Height / 2);
                    layer.AnchorPoint = new CCPoint(0.5f, 0.5f);
                    layer.IgnoreAnchorPointForPosition = true;
                    AddChild(layer, -1 - i);
                    
                }

                // create and initialize a Label
                CCLabelTTF label = new CCLabelTTF("Hello World", "Marker Felt", 64);
                CCMenuItem item1 = new CCMenuItemFont("restart", restart);

                CCMenu menu = new CCMenu(item1);
                menu.AlignItemsVertically();
                menu.Position = new CCPoint(size.Width / 2, 100);
                AddChild(menu);

                // position the label on the center of the screen
                label.Position = new CCPoint(size.Width / 2, size.Height / 2);

                // add the label as a child to this Layer
                AddChild(label);
                return true;
            }
            return false;
        }
예제 #20
0
        public LabelTTFTest()
        {
            var blockSize = new CCSize(200, 160);
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLayerColor colorLayer = new CCLayerColor(new CCColor4B(100, 100, 100, 255), blockSize.Width, blockSize.Height);
            colorLayer.AnchorPoint = new CCPoint(0, 0);
            colorLayer.Position = new CCPoint((s.Width - blockSize.Width) / 2, (s.Height - blockSize.Height) / 2);

            AddChild(colorLayer);

            CCMenuItemFont.FontSize = 30;
            CCMenu menu = new CCMenu(
                new CCMenuItemFont("Left", setAlignmentLeft),
                new CCMenuItemFont("Center", setAlignmentCenter),
                new CCMenuItemFont("Right", setAlignmentRight)
                );
            menu.AlignItemsVerticallyWithPadding(4);
            menu.Position = new CCPoint(50, s.Height / 2 - 20);
            AddChild(menu);

            menu = new CCMenu(
                new CCMenuItemFont("Top", setAlignmentTop),
                new CCMenuItemFont("Middle", setAlignmentMiddle),
                new CCMenuItemFont("Bottom", setAlignmentBottom)
                );
            menu.AlignItemsVerticallyWithPadding(4);
            menu.Position = new CCPoint(s.Width - 50, s.Height / 2 - 20);
            AddChild(menu);

            m_plabel = null;
            m_eHorizAlign = CCTextAlignment.CCTextAlignmentLeft;
            m_eVertAlign = CCVerticalTextAlignment.CCVerticalTextAlignmentTop;

            updateAlignment();
        }
예제 #21
0
        public FontTest()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;
            CCMenuItemImage item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback);

            CCMenu menu = new CCMenu(item1, item2, item3);
            menu.Position = CCPoint.Zero;
            item1.Position = new CCPoint(s.Width / 2 - item2.ContentSize.Width * 2, item2.ContentSize.Height / 2);
            item2.Position = new CCPoint(s.Width / 2, item2.ContentSize.Height / 2);
            item3.Position = new CCPoint(s.Width / 2 + item2.ContentSize.Width * 2, item2.ContentSize.Height / 2);
            AddChild(menu, 1);

            var blockSize = new CCSize(s.Width / 3, 200);

            CCLayerColor leftColor = new CCLayerColor(new CCColor4B(100, 100, 100, 255), blockSize.Width,
                                                      blockSize.Height);
            CCLayerColor centerColor = new CCLayerColor(new CCColor4B(200, 100, 100, 255), blockSize.Width,
                                                        blockSize.Height);
            CCLayerColor rightColor = new CCLayerColor(new CCColor4B(100, 100, 200, 255), blockSize.Width,
                                                       blockSize.Height);

            leftColor.IgnoreAnchorPointForPosition = false;
            centerColor.IgnoreAnchorPointForPosition = false;
            rightColor.IgnoreAnchorPointForPosition = false;

            leftColor.AnchorPoint = new CCPoint(0, 0.5f);
            centerColor.AnchorPoint = new CCPoint(0, 0.5f);
            rightColor.AnchorPoint = new CCPoint(0, 0.5f);

            leftColor.Position = new CCPoint(0, s.Height / 2);
            ;
            centerColor.Position = new CCPoint(blockSize.Width, s.Height / 2);
            rightColor.Position = new CCPoint(blockSize.Width * 2, s.Height / 2);

            AddChild(leftColor, -1);
            AddChild(rightColor, -1);
            AddChild(centerColor, -1);

            showFont(FontTestScene.restartAction());
        }
예제 #22
0
        public TMXUncompressedTest()
        {
            CCLayerColor color = new CCLayerColor(new CCColor4B(64, 64, 64, 255));
            AddChild(color, -1);

            CCTMXTiledMap map = CCTMXTiledMap.Create("TileMaps/iso-test2-uncompressed");
            AddChild(map, 0, kTagTileMap);

            CCSize s = map.ContentSize;

            // move map to the center of the screen
            CCSize ms = map.MapSize;
            CCSize ts = map.TileSize;
            map.RunAction(new CCMoveTo (1.0f, new CCPoint(-ms.Width * ts.Width / 2, -ms.Height * ts.Height / 2)));

            /*
            // testing release map
            CCArray* pChildrenArray = map.getChildren();
            CCTMXLayer layer;
            object* pObject = NULL;
            CCARRAY_FOREACH(pChildrenArray, pObject)
            {
                layer = (CCTMXLayer) pObject;

                if (!layer)
                    break;

                layer.releaseMap();
            }
            */
        }
예제 #23
0
        public TMXIsoTest2()
        {
            CCLayerColor color = new CCLayerColor(new CCColor4B(64, 64, 64, 255));
            AddChild(color, -1);

            CCTMXTiledMap map = CCTMXTiledMap.Create("TileMaps/iso-test22");
            AddChild(map, 0, kTagTileMap);

            CCSize s = map.ContentSize;

            // move map to the center of the screen
            CCSize ms = map.MapSize;
            CCSize ts = map.TileSize;
            map.RunAction(new CCMoveTo (1.0f, new CCPoint(-ms.Width * ts.Width / 2, -ms.Height * ts.Height / 2)));
        }
예제 #24
0
        public TMXIsoTest1()
        {
            CCLayerColor color = new CCLayerColor(new CCColor4B(64, 64, 64, 255));
            AddChild(color, -1);

            CCTMXTiledMap map = CCTMXTiledMap.Create("TileMaps/iso-test11");
            AddChild(map, 0, kTagTileMap);

            CCSize s = map.ContentSize;

            map.AnchorPoint = (new CCPoint(0.5f, 0.5f));
        }
예제 #25
0
        public TMXHexTest()
        {
            CCLayerColor color = new CCLayerColor(new CCColor4B(64, 64, 64, 255));
            AddChild(color, -1);

            CCTMXTiledMap map = CCTMXTiledMap.Create("TileMaps/hexa-test1");
            AddChild(map, 0, kTagTileMap);

            CCSize s = map.ContentSize;
        }
예제 #26
0
 public LayerMultiplexTest()
 {
     for (int i = 0; i < 3; i++)
     {
         CCLayer l = new CCLayerColor();
         CCSprite img = null;
         switch (i)
         {
             case 0:
                 img = new CCSprite("Images/grossini");
                 break;
             case 1:
                 img = new CCSprite("Images/grossinis_sister1");
                 break;
             case 2:
                 img = new CCSprite("Images/grossinis_sister2");
                 break;
         }
         img.AnchorPoint = CCPoint.Zero;
         img.Position = CCPoint.Zero;
         l.AddChild(img);
         l.Position = new CCPoint(128f, 128f);
         child.AddLayer(l);
     }
     child.InAction = new CCFadeIn(1);
     AddChild(child);
     Schedule(new Action<float>(AutoMultiplex), 3f);
 }
예제 #27
0
        public override void OnEnter()
        {

            base.OnEnter();

            m_tamara.RemoveFromParentAndCleanup(true);
            m_grossini.RemoveFromParentAndCleanup(true);
            m_kathia.RemoveFromParentAndCleanup(true);

			// Get window size so that we can center the box layer
			var winSize = CCDirector.SharedDirector.WinSize;

			var boxSize = new CCSize(100.0f, 100.0f);

            var box = new CCLayerColor(new CCColor4B(255, 255, 0, 255));
            box.AnchorPoint = new CCPoint(0, 0);
			box.Position = new CCPoint(winSize.Center.X - (boxSize.Width / 2), winSize.Center.Y - (boxSize.Height / 2));
            box.ContentSize = boxSize;

            var uL = new CCLayerColor(new CCColor4B(255, 0, 0, 255));
            box.AddChild(uL);
            uL.ContentSize = new CCSize(markrside, markrside);
            uL.Position = new CCPoint(0.0f, boxSize.Height - markrside);
            uL.AnchorPoint = new CCPoint(0, 0);

            var uR = new CCLayerColor(new CCColor4B(0, 0, 255, 255));
            box.AddChild(uR);
            uR.ContentSize = new CCSize(markrside, markrside);
            uR.Position = new CCPoint(boxSize.Width - markrside, boxSize.Height - markrside);
            uR.AnchorPoint = new CCPoint(0, 0);
            AddChild(box);

            var actionTo = new CCSkewTo (2, 0.0f, 2.0f);
            var rotateTo = new CCRotateTo (2, 61.0f);
            var actionScaleTo = new CCScaleTo(2, -0.44f, 0.47f);

            var actionScaleToBack = new CCScaleTo(2, 1.0f, 1.0f);
            var rotateToBack = new CCRotateTo (2, 0);
            var actionToBack = new CCSkewTo (2, 0, 0);

            box.RunAction(new CCSequence(actionTo, actionToBack));
            box.RunAction(new CCSequence(rotateTo, rotateToBack));
            box.RunAction(new CCSequence(actionScaleTo, actionScaleToBack));
        }
예제 #28
0
        public override void OnEnter()
        {
            base.OnEnter();

            m_tamara.RemoveFromParentAndCleanup(true);
            m_grossini.RemoveFromParentAndCleanup(true);
            m_kathia.RemoveFromParentAndCleanup(true);

            var s = CCDirector.SharedDirector.WinSize;

            CCSize boxSize = new CCSize(100.0f, 100.0f);

            CCLayerColor box = new CCLayerColor(new CCColor4B(255, 255, 0, 255));
            box.AnchorPoint = new CCPoint(0.5f, 0.5f);
            box.ContentSize = boxSize;
            box.IgnoreAnchorPointForPosition = false;
            box.Position = new CCPoint(s.Width / 2, s.Height - 100 - box.ContentSize.Height / 2);
            this.AddChild(box);
            CCLabelTTF label = new CCLabelTTF("Standard cocos2d Skew", "Marker Felt", 16);
            label.Position = new CCPoint(s.Width / 2, s.Height - 100 + label.ContentSize.Height);
            this.AddChild(label);
            CCSkewBy actionTo = new CCSkewBy(2, 360, 0);
            CCSkewBy actionToBack = new CCSkewBy(2, -360, 0);

            box.RunAction(new CCSequence(actionTo, actionToBack));

            box = new CCLayerColor(new CCColor4B(255, 255, 0, 255));
            box.AnchorPoint = new CCPoint(0.5f, 0.5f);
            box.ContentSize = boxSize;
            box.IgnoreAnchorPointForPosition = false;
            box.Position = new CCPoint(s.Width / 2, s.Height - 250 - box.ContentSize.Height / 2);
            this.AddChild(box);
            label = new CCLabelTTF("Rotational Skew", "Marker Felt", 16);
            label.Position = new CCPoint(s.Width / 2, s.Height - 250 + label.ContentSize.Height / 2);
            this.AddChild(label);
            CCRotateBy actionTo2 = new CCRotateBy(2, 360, 0);
            CCRotateBy actionToBack2 = new CCRotateBy(2, -360, 0);
            box.RunAction(new CCSequence(actionTo2, actionToBack2));
        }
예제 #29
0
        public override void OnEnter()
        {
            base.OnEnter();

            var s = CCDirector.SharedDirector.WinSize;
            var layer1 = new CCLayerColor(new CCColor4B(192, 0, 0, 255), s.Width, s.Height / 2);
            layer1.CascadeColorEnabled = false;

            layer1.Position = new CCPoint(0, s.Height / 2);

            var sister1 = new CCSprite("Images/grossinis_sister1.png");
            var sister2 = new CCSprite("Images/grossinis_sister2.png");
            var label = new CCLabelBMFont("Test", "fonts/bitmapFontTest.fnt");

            layer1.AddChild(sister1);
            layer1.AddChild(sister2);
            layer1.AddChild(label);
            this.AddChild(layer1, 0, kTagLayer);

            sister1.Position = new CCPoint(s.Width * 1 / 3, 0);
            sister2.Position = new CCPoint(s.Width * 2 / 3, 0);
            label.Position = new CCPoint(s.Width / 2, 0);

            layer1.RunAction(
                new CCRepeatForever(
                    CCSequence.FromActions(
                        new CCTintTo(6, 255, 0, 255),
                        new CCTintTo(6, 255, 255, 255),
                        new CCDelayTime(1))
                    )
                );

            sister1.RunAction(
                new CCRepeatForever(
                    CCSequence.FromActions(
                        new CCTintTo(2, 255, 255, 0),
                        new CCTintTo(2, 255, 255, 255),
                        new CCTintTo(2, 0, 255, 255),
                        new CCTintTo(2, 255, 255, 255),
                        new CCTintTo(2, 255, 0, 255),
                        new CCTintTo(2, 255, 255, 255),
                        new CCDelayTime(1))
                    )
                );
        }
예제 #30
0
        public void showFont(string pFont)
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            var blockSize = new CCSize(s.Width / 3, 200);
            float fontSize = 26;

            RemoveChildByTag(kTagLabel1, true);
            RemoveChildByTag(kTagLabel2, true);
            RemoveChildByTag(kTagLabel3, true);
            RemoveChildByTag(kTagLabel4, true);

            CCLabelTTF top = new CCLabelTTF(pFont, pFont, 24);
            CCLabelTTF left = new CCLabelTTF("alignment left", pFont, fontSize,
                                                blockSize, CCTextAlignment.CCTextAlignmentLeft,
                                                FontTestScene.verticalAlignment[FontTestScene.vAlignIdx]);
            CCLabelTTF center = new CCLabelTTF("alignment center", pFont, fontSize,
                                                  blockSize, CCTextAlignment.CCTextAlignmentCenter,
                                                  FontTestScene.verticalAlignment[FontTestScene.vAlignIdx]);
            CCLabelTTF right = new CCLabelTTF("alignment right", pFont, fontSize,
                                                 blockSize, CCTextAlignment.CCTextAlignmentRight,
                                                 FontTestScene.verticalAlignment[FontTestScene.vAlignIdx]);

            CCLayerColor leftColor = new CCLayerColor(new CCColor4B(100, 100, 100, 255), blockSize.Width, blockSize.Height);
            CCLayerColor centerColor = new CCLayerColor(new CCColor4B(200, 100, 100, 255), blockSize.Width, blockSize.Height);
            CCLayerColor rightColor = new CCLayerColor(new CCColor4B(100, 100, 200, 255), blockSize.Width, blockSize.Height);

            leftColor.IgnoreAnchorPointForPosition = false;
            centerColor.IgnoreAnchorPointForPosition = false;
            rightColor.IgnoreAnchorPointForPosition = false;


            top.AnchorPoint = new CCPoint(0.5f, 1);
            left.AnchorPoint = new CCPoint(0, 0.5f);
            leftColor.AnchorPoint = new CCPoint(0, 0.5f);
            center.AnchorPoint = new CCPoint(0, 0.5f);
            centerColor.AnchorPoint = new CCPoint(0, 0.5f);
            right.AnchorPoint = new CCPoint(0, 0.5f);
            rightColor.AnchorPoint = new CCPoint(0, 0.5f);

            top.Position = new CCPoint(s.Width / 2, s.Height - 20);
            left.Position = new CCPoint(0, s.Height / 2);
            leftColor.Position = left.Position;
            center.Position = new CCPoint(blockSize.Width, s.Height / 2);
            centerColor.Position = center.Position;
            right.Position = new CCPoint(blockSize.Width * 2, s.Height / 2);
            rightColor.Position = right.Position;

            AddChild(leftColor, -1);
            AddChild(left, 0, kTagLabel1);
            AddChild(rightColor, -1);
            AddChild(right, 0, kTagLabel2);
            AddChild(centerColor, -1);
            AddChild(center, 0, kTagLabel3);
            AddChild(top, 0, kTagLabel4);
        }