Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public override void onEnter()
        {
            base.onEnter();

            CCSize s = CCDirector.sharedDirector().getWinSize();

            CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 24);

            addChild(label);
            label.position = new CCPoint(s.width / 2, s.height - 50);

            string subTitle = m_pNotificationLayer.subtitle();

            if (subTitle != null)
            {
                CCLabelTTF l = CCLabelTTF.labelWithString(subTitle, "Thonburi", 16);
                addChild(l, 1);
                l.position = new CCPoint(s.width / 2, s.height - 80);
            }

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

            CCMenu menu = CCMenu.menuWithItems(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);
        }
Ejemplo n.º 3
0
        public override void onEnter()
        {
            base.onEnter();

            CCSize s = CCDirector.sharedDirector().getWinSize();

            CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 28);

            addChild(label, 1);
            label.position = new CCPoint(s.width / 2, s.height - 50);

            string strSubtitle = subtitle();

            if (strSubtitle != null)
            {
                CCLabelTTF l = CCLabelTTF.labelWithString(strSubtitle, "Arial", 16);
                addChild(l, 1);
                l.position = new CCPoint(s.width / 2, s.height - 80);
            }

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

            CCMenu menu = CCMenu.menuWithItems(item1, item2, item3);

            menu.position  = new CCPoint();
            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);
        }
Ejemplo n.º 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)CCSequence.FromActions(
                                                                       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 = CCMenuItemLabel.Create(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;
        }
Ejemplo n.º 5
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = CCDirector.SharedDirector.WinSize;

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

            string strSubtitle = subtitle();
            if (!string.IsNullOrEmpty(strSubtitle))
            {
                CCLabelTTF l = new CCLabelTTF(strSubtitle, "arial", 16);
                //CCLabelTTF l = CCLabelTTF.labelWithString(strSubtitle, "Thonburi", 16);
                AddChild(l, 1);
                l.Position = new CCPoint(s.Width / 2, s.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();
            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);
        }
Ejemplo n.º 6
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCApplication.SharedApplication.GamePadButtonUpdate += _GamePadButtonDelegate;
            CCApplication.SharedApplication.GamePadDPadUpdate += _GamePadDPadDelegate;
            CCApplication.SharedApplication.GamePadStickUpdate += _GamePadStickDelegate;
            CCApplication.SharedApplication.GamePadTriggerUpdate += _GamePadTriggerDelegate;

            CCSize s = CCDirector.SharedDirector.WinSize;

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

            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);
        }
Ejemplo n.º 7
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;
        }
Ejemplo n.º 8
0
        public override bool Init()
        {
            InitWithColor(new CCColor4B(0, 0, 255, 255));

            CCMenuItemFont item1 = CCMenuItemFont.Create("(3) Touch to pushScene (self)", item0Clicked);
            CCMenuItemFont item2 = CCMenuItemFont.Create("(3) Touch to popScene", item1Clicked);
            CCMenuItemFont item3 = CCMenuItemFont.Create("(3) Touch to popToRootScene", item2Clicked);

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

            AddChild(menu);

            CCSize s = CCDirector.SharedDirector.WinSize;
            CCSprite sprite = new CCSprite(s_pPathGrossini);
            AddChild(sprite);

            sprite.Position = new CCPoint(s.Width /2, 40);
            CCActionInterval rotate = new CCRotateBy (2, 360);
            CCAction repeat = new CCRepeatForever (rotate);
            sprite.RunAction(repeat);

            Schedule(testDealloc);

            return true;
        }
Ejemplo n.º 9
0
        public override void OnEnter()
        {
            base.OnEnter();

            var s = CCDirector.SharedDirector.WinSize;

            CCMenuItemFont.FontName = "arial";
            CCMenuItemFont.FontSize = 24;
            var pMainItem = new CCMenuItemFont("Back", toMainLayer);
            pMainItem.Position = new CCPoint(s.Width - 50, 25);
            var pMenu = new CCMenu(pMainItem);
            pMenu.Position = new CCPoint(0, 0);

            if (m_bControlMenuVisible)
            {
                var item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback);
                var item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback);
                var item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback);
                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);

                pMenu.AddChild(item1, PerformanceTestScene.kItemTagBasic);
                pMenu.AddChild(item2, PerformanceTestScene.kItemTagBasic);
                pMenu.AddChild(item3, PerformanceTestScene.kItemTagBasic);
            }
            AddChild(pMenu);
        }
Ejemplo n.º 10
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = CCDirector.SharedDirector.WinSize;

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

            string subtitle_ = subtitle();
            if (subtitle_.Length > 0)
            {
                CCLabelTTF l = new CCLabelTTF(subtitle_, "arial", 16);
                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);
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
        public void reset()
        {
            int localtag = 0;
            localtag++;

            // TO TRIGGER THE BUG:
            // remove the itself from parent from an action
            // The menu will be removed, but the instance will be alive
            // and then a new node will be allocated occupying the memory.
            // => CRASH BOOM BANG
            CCNode node = GetChildByTag(localtag - 1);
            CCLog.Log("Menu: %p", node);
            RemoveChild(node, false);
            //	[self removeChildByTag:localtag-1 cleanup:NO];

            CCMenuItem item1 = CCMenuItemFont.Create("One", menuCallback);
            CCLog.Log("MenuItemFont: %p", item1);
            CCMenuItem item2 = CCMenuItemFont.Create("Two", menuCallback);
            CCMenu menu = new CCMenu(item1, item2);
            menu.AlignItemsVertically();

            float x = Random.Next() * 50;
            float y = Random.Next() * 50;
            menu.Position = CCPointExtension.Add(menu.Position, new CCPoint(x, y));
            AddChild(menu, 0, localtag);

            //[self check:self];
        }
Ejemplo n.º 13
0
        public MenuLayerPriorityTest()
        {
            // Testing empty menu
            m_pMenu1 = new CCMenu();
            m_pMenu2 = new CCMenu();

            // Menu 1
            CCMenuItemFont item1 = new CCMenuItemFont("Return to Main Menu", menuCallback);
            CCMenuItemFont item2 = new CCMenuItemFont("Disable menu for 5 seconds", disableMenuCallback);

            m_pMenu1.AddChild(item1);
            m_pMenu1.AddChild(item2);

            m_pMenu1.AlignItemsVerticallyWithPadding(2);

            AddChild(m_pMenu1);

            // Menu 2
            m_bPriority = true;
            //CCMenuItemFont.setFontSize(48);
            item1 = new CCMenuItemFont("Toggle priority", togglePriorityCallback);
            item1.Scale = 1.5f;
            item1.Color = new CCColor3B(0, 0, 255);
            m_pMenu2.AddChild(item1);
            AddChild(m_pMenu2);
        }
Ejemplo n.º 14
0
        public override bool Init()
        {
            if (!base.Init())
                return false;

            var winSize = CCDirector.SharedDirector.WinSize;

            var tableView = new CCTableView(this, new CCSize(250, 60));
            tableView.Direction = CCScrollViewDirection.Horizontal;
            tableView.Position = new CCPoint(20,winSize.Height/2-30);
            tableView.Delegate = this;
            this.AddChild(tableView);
            tableView.ReloadData();

            tableView = new CCTableView(this, new CCSize(60, 280));
            tableView.Direction = CCScrollViewDirection.Vertical;
            tableView.Position = new CCPoint(winSize.Width - 150, winSize.Height/2 - 120);
            tableView.Delegate = this;
            tableView.VerticalFillOrder = CCTableViewVerticalFillOrder.FillTopDown;
            this.AddChild(tableView);
            tableView.ReloadData();

            // Back Menu
            var itemBack = new CCMenuItemFont("Back", toExtensionsMainLayer);
            itemBack.Position = new CCPoint(winSize.Width - 50, 25);
            var menuBack = new CCMenu(itemBack);
            menuBack.Position = CCPoint.Zero;
            AddChild(menuBack);

            return true;
        }
Ejemplo n.º 15
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = CCDirector.SharedDirector.WinSize;

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

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

            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 = 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);
        }
Ejemplo n.º 16
0
        public RenderTextureSave()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            // create a render texture, this is what we are going to draw into
            m_pTarget = CCRenderTexture.Create((int) s.Width, (int) s.Height, SurfaceFormat.Color, DepthFormat.None, RenderTargetUsage.PreserveContents);
            m_pTarget.Position = new CCPoint(s.Width / 2, s.Height / 2);

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

            // note that the render texture is a CCNode, and contains a sprite of its texture for convience,
            // so we can just parent it to the scene like any other CCNode
            AddChild(m_pTarget, -1);

            // create a brush image to draw into the texture with
            m_pBrush = new CCSprite("Images/fire");
            // It's possible to modify the Brushes blending function by
            CCBlendFunc bbf = new CCBlendFunc (OGLES.GL_ONE, OGLES.GL_ONE_MINUS_SRC_ALPHA);
            m_pBrush.BlendFunc = bbf;

            m_pBrush.Color = new CCColor3B (Color.Red);
            m_pBrush.Opacity = 20;
            TouchEnabled = true;

            // Save Image menu
            CCMenuItemFont.FontSize = 16;
            CCMenuItem item1 = CCMenuItemFont.Create("Save Image", saveImage);
            CCMenuItem item2 = CCMenuItemFont.Create("Clear", clearImage);
            var menu = new CCMenu(item1, item2);
            AddChild(menu);
            menu.AlignItemsVertically();
            menu.Position = new CCPoint(s.Width - 80, s.Height - 30);
        }
Ejemplo n.º 17
0
        public IntervalLayer()
        {
            m_time0 = m_time1 = m_time2 = m_time3 = m_time4 = 0.0f;

            CCSize s = CCDirector.SharedDirector.WinSize;

            // sun
            CCParticleSystem sun = CCParticleSun.Create();
            sun.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire");
            sun.Position = (new CCPoint(s.Width - 32, s.Height - 32));

            sun.TotalParticles = 130;
            sun.Life = (0.6f);
            AddChild(sun);

            // timers
            m_label0 = CCLabelBMFont.Create("0", "fonts/bitmapFontTest4.fnt");
            m_label1 = CCLabelBMFont.Create("0", "fonts/bitmapFontTest4.fnt");
            m_label2 = CCLabelBMFont.Create("0", "fonts/bitmapFontTest4.fnt");
            m_label3 = CCLabelBMFont.Create("0", "fonts/bitmapFontTest4.fnt");
            m_label4 = CCLabelBMFont.Create("0", "fonts/bitmapFontTest4.fnt");

            ScheduleUpdate();

            Schedule(step1);
            Schedule(step2, 0);
            Schedule(step3, 1.0f);
            Schedule(step4, 2.0f);

            m_label0.Position = new CCPoint(s.Width * 1 / 6, s.Height / 2);
            m_label1.Position = new CCPoint(s.Width * 2 / 6, s.Height / 2);
            m_label2.Position = new CCPoint(s.Width * 3 / 6, s.Height / 2);
            m_label3.Position = new CCPoint(s.Width * 4 / 6, s.Height / 2);
            m_label4.Position = new CCPoint(s.Width * 5 / 6, s.Height / 2);

            AddChild(m_label0);
            AddChild(m_label1);
            AddChild(m_label2);
            AddChild(m_label3);
            AddChild(m_label4);

            // Sprite
            CCSprite sprite = new CCSprite(s_pPathGrossini);
            sprite.Position = new CCPoint(40, 50);

            CCJumpBy jump = new CCJumpBy (3, new CCPoint(s.Width - 80, 0), 50, 4);

            AddChild(sprite);
            sprite.RunAction(new CCRepeatForever (
                (CCActionInterval) (CCSequence.FromActions(jump, jump.Reverse())))
                );

            // pause button
            CCMenuItem item1 = CCMenuItemFont.Create("Pause", onPause);
            CCMenu menu = new CCMenu(item1);
            menu.Position = new CCPoint(s.Width / 2, s.Height - 50);

            AddChild(menu);
        }
Ejemplo n.º 18
0
        public TextLayer()
        {
            InitWithColor(CCTypes.CreateColor(32, 32, 32, 255));

            float x, y;

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

            CCNode node = new CCNode ();
            CCActionInterval effect = getAction();
            node.RunAction(effect);
            AddChild(node, 0, EffectTestScene.kTagBackground);

            CCSprite bg = new CCSprite(TestResource.s_back3);
            node.AddChild(bg, 0);
            bg.AnchorPoint = new CCPoint(0.5f, 0.5f);
            bg.Position = new CCPoint(size.Width / 2, size.Height / 2);

            CCSprite grossini = new CCSprite(TestResource.s_pPathSister2);
            node.AddChild(grossini, 1);
            grossini.Position = new CCPoint(x / 3, y / 2);
            CCActionInterval sc = new CCScaleBy(2, 5);
            CCFiniteTimeAction sc_back = sc.Reverse();
            grossini.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc, sc_back))));
            //grossini.runAction(effect);

            CCSprite tamara = new CCSprite(TestResource.s_pPathSister1);
            node.AddChild(tamara, 1);
            tamara.Position = new CCPoint(2 * x / 3, y / 2);
            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(EffectTestScene.effectsList[EffectTestScene.actionIdx], "arial", 32);

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

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

            Schedule(checkAnim);
        }
Ejemplo n.º 19
0
        public static CCMenu menuWithItems(params CCMenuItem[] item)
        {
            CCMenu cCMenu = new CCMenu();

            if (cCMenu != null && cCMenu.initWithItems(item))
            {
                return(cCMenu);
            }
            return(null);
        }
Ejemplo n.º 20
0
        public static new CCMenu node()
        {
            CCMenu cCMenu = new CCMenu();

            if (cCMenu != null && cCMenu.init())
            {
                return(cCMenu);
            }
            return(null);
        }
 public SceneSelect()
 {
     base.init();
     #region SanguoCommander4
     //����ͼ
     CCSprite background = CCSprite.spriteWithSpriteFrameName("bg_select.png");
     background.anchorPoint = new CCPoint(0, 0);
     this.addChild(background);
     //���ذ�ť
     CCMenuItemSprite btn_back = CCMenuItemSprite.itemFromNormalSprite(
         CCSprite.spriteWithSpriteFrameName("btn_back1.png"),
         CCSprite.spriteWithSpriteFrameName("btn_back2.png"),
         this, click_back);
     CCMenu menu = CCMenu.menuWithItems(btn_back);
     menu.position = new CCPoint(666, 32);
     this.addChild(menu);
     //�����Tab��ť����
     CCMenuItemSprite tab1 = CCMenuItemSprite.itemFromNormalSprite(
         CCSprite.spriteWithSpriteFrameName("tab_shu2.png"),
         CCSprite.spriteWithSpriteFrameName("tab_shu1.png"),
         CCSprite.spriteWithSpriteFrameName("tab_shu1.png"),
         this, click_story_tab);
     CCMenuItemSprite tab2 = CCMenuItemSprite.itemFromNormalSprite(
         CCSprite.spriteWithSpriteFrameName("tab_wu2.png"),
         CCSprite.spriteWithSpriteFrameName("tab_wu1.png"),
         CCSprite.spriteWithSpriteFrameName("tab_wu1.png"),
         this, click_story_tab);
     CCMenuItemSprite tab3 = CCMenuItemSprite.itemFromNormalSprite(
         CCSprite.spriteWithSpriteFrameName("tab_wei2.png"),
         CCSprite.spriteWithSpriteFrameName("tab_wei1.png"),
         CCSprite.spriteWithSpriteFrameName("tab_wei1.png"),
         this, click_story_tab);
     story_tabs = CCMenu.menuWithItems(tab1, tab2, tab3);
     //����ˮƽ����10�����ؼ��ָ�
     story_tabs.alignItemsHorizontallyWithPadding(10);
     //ת��Ϊ����UI������
     story_tabs.position = CCDirector.sharedDirector().convertToUI(new CCPoint(300, 72));
     //����һ������Ϊ���ɵ��
     tab1.Enabled = false;
     this.addChild(story_tabs);
     //��Ӳ��Բ�
     //this.addChild(new LayerLevels());
     //����ǩ��Ӧ����ͬ��LyerLevers ����
     dictLayerLevels.Add(tab1, new LayerLevels() { visible = false });
     dictLayerLevels.Add(tab2, new LayerLevels() { visible = false });
     dictLayerLevels.Add(tab3, new LayerLevels() { visible = false });
     //��tab1��ʾΪ��ǰ�Ĺؿ���
     showLayerLevels(dictLayerLevels[tab1]);
     //��������ӵ�������
     foreach (var item in dictLayerLevels.Values)
     {
         this.addChild(item);
     }
     #endregion
 }
Ejemplo n.º 22
0
        /// <summary>
        /// creates an empty CCMenu
        /// </summary>
        public static CCMenu node()
        {
            CCMenu menu = new CCMenu();

            if (menu != null && menu.init())
            {
                return(menu);
            }

            return(null);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// creates a CCMenu with it's items
        /// </summary>
        public static CCMenu menuWithItems(params CCMenuItem[] item)
        {
            CCMenu pRet = new CCMenu();

            if (pRet != null && pRet.initWithItems(item))
            {
                return(pRet);
            }

            return(null);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// creates an empty CCMenu
        /// </summary>
        public static CCMenu node()
        {
            CCMenu menu = new CCMenu();

            if (menu != null && menu.init())
            {
                return menu;
            }

            return null;
        }
Ejemplo n.º 25
0
        /// <summary>
        /// creates a CCMenu with it's items
        /// </summary>
        public static CCMenu menuWithItems(params CCMenuItem[] item)
        {
            CCMenu pRet = new CCMenu();

            if (pRet != null && pRet.initWithItems(item))
            {
                return pRet;
            }

            return null;
        }
Ejemplo n.º 26
0
        public CocosDenshionTest()
        {
            m_pItmeMenu = null;
            m_tBeginPos = new CCPoint(0,0);
            m_nSoundId = 0;

            string[] testItems = {
                "play background music",
                "stop background music",
                "pause background music",
                "resume background music",
                "rewind background music",
                "is background music playing",
                "play effect",
                "play effect repeatly",
                "stop effect",
                "unload effect",
                "add background music volume",
                "sub background music volume",
                "add effects volume",
                "sub effects volume"
            };

            // add menu items for tests
            m_pItmeMenu = new CCMenu(null);
            CCSize s = CCDirector.SharedDirector.WinSize;
            m_nTestCount = testItems.Count<string>();

            for (int i = 0; i < m_nTestCount; ++i)
            {
                CCLabelTTF label = new CCLabelTTF(testItems[i], "arial", 24);
                CCMenuItemLabel pMenuItem = CCMenuItemLabel.Create(label, new SEL_MenuHandler(menuCallback));

                m_pItmeMenu.AddChild(pMenuItem, i + 10000);
                pMenuItem.Position = new CCPoint( s.Width / 2, (s.Height - (i + 1) * LINE_SPACE) );
            }

            m_pItmeMenu.ContentSize = new CCSize(s.Width, (m_nTestCount + 1) * LINE_SPACE);
            m_pItmeMenu.Position = new CCPoint(0,0);
            AddChild(m_pItmeMenu);

            this.TouchEnabled = true;

            // preload background music and effect
            SimpleAudioEngine.SharedEngine.PreloadBackgroundMusic(CCFileUtils.FullPathFromRelativePath(MUSIC_FILE));
            SimpleAudioEngine.SharedEngine.PreloadEffect(CCFileUtils.FullPathFromRelativePath(EFFECT_FILE));

            // set default volume
            SimpleAudioEngine.SharedEngine.EffectsVolume = 0.5f;
            SimpleAudioEngine.SharedEngine.BackgroundMusicVolume = 0.5f;
        }
        public CocosDenshionTest()
        {
            m_pItmeMenu = null;
            m_tBeginPos = new CCPoint(0,0);
            m_nSoundId = 0;

            string[] testItems = {
                "play background music",
                "stop background music",
                "pause background music",
                "resume background music",
                "rewind background music",
                "is background music playing",
                "play effect",
                "play effect repeatly",
                "stop effect",
                "unload effect",
                "add background music volume",
                "sub background music volume",
                "add effects volume",
                "sub effects volume"
            };

            // add menu items for tests
            m_pItmeMenu = CCMenu.menuWithItems(null);
            CCSize s = CCDirector.sharedDirector().getWinSize();
            m_nTestCount = testItems.Count<string>();

            for (int i = 0; i < m_nTestCount; ++i)
            {
                CCLabelTTF label = CCLabelTTF.labelWithString(testItems[i], "Arial", 24);
                CCMenuItemLabel pMenuItem = CCMenuItemLabel.itemWithLabel(label, this, new SEL_MenuHandler(menuCallback));

                m_pItmeMenu.addChild(pMenuItem, i + 10000);
                pMenuItem.position = new CCPoint( s.width / 2, (s.height - (i + 1) * LINE_SPACE) );
            }

            m_pItmeMenu.contentSize = new CCSize(s.width, (m_nTestCount + 1) * LINE_SPACE);
            m_pItmeMenu.position = new CCPoint(0,0);
            addChild(m_pItmeMenu);

            this.isTouchEnabled = true;

            // preload background music and effect
            SimpleAudioEngine.sharedEngine().preloadBackgroundMusic(CCFileUtils.fullPathFromRelativePath(MUSIC_FILE));
            SimpleAudioEngine.sharedEngine().preloadEffect(CCFileUtils.fullPathFromRelativePath(EFFECT_FILE));

            // set default volume
            SimpleAudioEngine.sharedEngine().setEffectsVolume(0.5f);
            SimpleAudioEngine.sharedEngine().setBackgroundMusicVolume(0.5f);
        }
Ejemplo n.º 28
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = CCDirector.SharedDirector.WinSize;

            CCMenuItemFont.FontName = "arial";
            CCMenuItemFont.FontSize = 24;
            CCMenuItemFont pMainItem = CCMenuItemFont.Create("Back",
                backCallback);
            pMainItem.Position = new CCPoint(s.Width - 50, 25);
            CCMenu pMenu = new CCMenu(pMainItem, null);
            pMenu.Position = new CCPoint(0, 0);
            AddChild(pMenu);
        }
Ejemplo n.º 29
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);

            showFont(FontTestScene.restartAction());
        }
Ejemplo n.º 30
0
        public override void OnEnter()
        {
            base.OnEnter();

            //add the menu item for back to main menu
            CCLabelTTF label = new CCLabelTTF("MainMenu", "arial", 20);
            CCMenuItemLabel pMenuItem = CCMenuItemLabel.Create(label, MainMenuCallback);

            CCMenu pMenu = new CCMenu(pMenuItem);
            CCSize s = CCDirector.SharedDirector.WinSize;
            pMenu.Position = CCPoint.Zero;
            pMenuItem.Position = new CCPoint(s.Width - 50, 25);

            AddChild(pMenu, 1);
            CCApplication.SharedApplication.GamePadDPadUpdate += _GamePadDPadDelegate;
            CCApplication.SharedApplication.GamePadButtonUpdate += _GamePadButtonDelegate;
        }
Ejemplo n.º 31
0
        public override bool Init()
        {
            if (base.Init())
            {
                // Get the sceensize
                CCSize screensize = CCDirector.SharedDirector.WinSize;

                var pBackItem = new CCMenuItemFont("Back", toExtensionsMainLayer);
                pBackItem.Position = new CCPoint(screensize.Width - 50, 25);
                var pBackMenu = new CCMenu(pBackItem);
                pBackMenu.Position =  CCPoint.Zero;
                AddChild(pBackMenu, 10);

                // Add the generated background
                var background = new CCSprite("extensions/background");
                background.Position = new CCPoint(screensize.Width / 2, screensize.Height / 2);
                AddChild(background);

                // Add the ribbon
                var ribbon = new CCScale9SpriteFile("extensions/ribbon", new CCRect(1, 1, 48, 55));
                ribbon.ContentSize = new CCSize(screensize.Width, 57);
                ribbon.Position = new CCPoint(screensize.Width / 2.0f, screensize.Height - ribbon.ContentSize.Height / 2.0f);
                AddChild(ribbon);

                // Add the title
                setSceneTitleLabel(new CCLabelTTF("Title", "arial", 12));
                m_pSceneTitleLabel.Position = new CCPoint(screensize.Width / 2, screensize.Height - m_pSceneTitleLabel.ContentSize.Height / 2 - 5);
                AddChild(m_pSceneTitleLabel, 1);

                // Add the menu
                var item1 = new CCMenuItemImage("Images/b1", "Images/b2", previousCallback);
                var item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback);
                var item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback);

                var menu = new CCMenu(item1, item3, item2);
                menu.Position = CCPoint.Zero;
                item1.Position = new CCPoint(screensize.Width / 2 - 100, 37);
                item2.Position = new CCPoint(screensize.Width / 2, 35);
                item3.Position = new CCPoint(screensize.Width / 2 + 100, 37);

                AddChild(menu ,1);

                return true;
            }
            return false;
        }
Ejemplo n.º 32
0
        public virtual void initWithQuantityOfNodes(int nNodes)
        {
            //srand(time());
            CCSize s = CCDirector.SharedDirector.WinSize;

            // Title
            CCLabelTTF label = new CCLabelTTF(title(), "arial", 32);
            AddChild(label, 1);
            label.Position = new CCPoint(s.Width / 2, s.Height - 32);
            label.Color = new CCColor3B(255, 255, 40);

            // Subtitle
            string strSubTitle = subtitle();
            if (strSubTitle.Length > 0)
            {
                CCLabelTTF l = new CCLabelTTF(strSubTitle, "arial", 16);
                AddChild(l, 1);
                l.Position = new CCPoint(s.Width / 2, s.Height - 80);
            }

            lastRenderedCount = 0;
            currentQuantityOfNodes = 0;
            quantityOfNodes = nNodes;

            CCMenuItemFont.FontSize = 64;
            CCMenuItemFont decrease = new CCMenuItemFont(" - ", onDecrease);
            decrease.Color = new CCColor3B(0, 200, 20);
            CCMenuItemFont increase = new CCMenuItemFont(" + ", onIncrease);
            increase.Color = new CCColor3B(0, 200, 20);

            CCMenu menu = new CCMenu(decrease, increase);
            menu.AlignItemsHorizontally();
            menu.Position = new CCPoint(s.Width / 2, s.Height / 2 + 15);
            AddChild(menu, 1);

            CCLabelTTF infoLabel = new CCLabelTTF("0 nodes", "arial", 30);
            infoLabel.Color = new CCColor3B(0, 200, 20);
            infoLabel.Position = new CCPoint(s.Width / 2, s.Height / 2 - 15);
            AddChild(infoLabel, 1, PerformanceNodeChildrenTest.kTagInfoLayer);

            NodeChildrenMenuLayer pMenu = new NodeChildrenMenuLayer(true, PerformanceNodeChildrenTest.TEST_COUNT, PerformanceNodeChildrenTest.s_nCurCase);
            AddChild(pMenu);

            updateQuantityLabel();
            updateQuantityOfNodes();
        }
Ejemplo n.º 33
0
        public LayerGradient()
        {
            CCLayerGradient layer1 = CCLayerGradient.Create(new CCColor4B(255, 0, 0, 255), new CCColor4B(0, 255, 0, 255), new CCPoint(0.9f, 0.9f));
            AddChild(layer1, 0, kTagLayer);

            this.TouchEnabled = true;

            CCLabelTTF label1 = new CCLabelTTF("Compressed Interpolation: Enabled", "arial", 26);
            CCLabelTTF label2 = new CCLabelTTF("Compressed Interpolation: Disabled", "arial", 26);
            CCMenuItemLabel item1 = CCMenuItemLabel.Create(label1);
            CCMenuItemLabel item2 = CCMenuItemLabel.Create(label2);
            CCMenuItemToggle item = CCMenuItemToggle.Create((toggleItem), item1, item2);

            CCMenu menu = new CCMenu(item);
            AddChild(menu);
            CCSize s = CCDirector.SharedDirector.WinSize;
            menu.Position = (new CCPoint(s.Width / 2, 100));
        }
Ejemplo n.º 34
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = CCDirector.SharedDirector.WinSize;

            CCMenu pMenu = new CCMenu(null);
            pMenu.Position = new CCPoint(0, 0);
            CCMenuItemFont.FontName = "arial";
            CCMenuItemFont.FontSize = 24;
            for (int i = 0; i < PerformanceTestScene.MAX_COUNT; ++i)
            {
                CCMenuItemFont pItem = new CCMenuItemFont(PerformanceTestScene.testsName[i], menuCallback);
                pItem.Position = new CCPoint(s.Width / 2, s.Height - (i + 1) * PerformanceTestScene.LINE_SPACE);
                pMenu.AddChild(pItem, PerformanceTestScene.kItemTagBasic + i);
            }

            AddChild(pMenu);
        }
Ejemplo n.º 35
0
        public override void OnEnter()
        {
            base.OnEnter();

            var	s = CCDirector.SharedDirector.WinSize;

            var pMenu = new CCMenu();
            pMenu.Position = CCPoint.Zero;
            CCMenuItemFont.FontName = "arial";
            CCMenuItemFont.FontSize = 24;
            for (int i = 0; i < ExtensionsTestScene.TEST_MAX_COUNT; ++i)
            {
                var pItem = new CCMenuItemFont(ExtensionsTestScene.testsName[i], menuCallback);
                pItem.Position = new CCPoint(s.Width / 2, s.Height - (i + 1) * ExtensionsTestScene.LINE_SPACE);
                pMenu.AddChild(pItem, ExtensionsTestScene.kItemTagBasic + i);
            }

            AddChild(pMenu);
        }
Ejemplo n.º 36
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = CCDirector.SharedDirector.WinSize;
            m_pItmeMenu = new CCMenu(null);
            CCMenuItemFont.FontName = "arial";
            CCMenuItemFont.FontSize = 24;
            for (int i = 0; i < BugsTestScene.MAX_COUNT; ++i)
            {
                CCMenuItemFont pItem = CCMenuItemFont.Create(BugsTestScene.testsName[i],
                                                            menuCallback);
                pItem.Position = new CCPoint(s.Width / 2, s.Height - (i + 1) * BugsTestScene.LINE_SPACE);
                m_pItmeMenu.AddChild(pItem, BugsTestScene.kItemTagBasic + i);
            }

            m_pItmeMenu.Position = BugsTestScene.s_tCurPos;
            AddChild(m_pItmeMenu);
            TouchEnabled = true;
        }
Ejemplo n.º 37
0
 public static CCMenu menuWithItem(CCMenuItem item)
 {
     return(CCMenu.menuWithItems(new CCMenuItem[] { item }));
 }