示例#1
0
        public LayerLevels()
        {
            //关卡选择层
            CCPoint offset = new CCPoint(170, 180);

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    //关卡的按钮
                    CCMenuItemSprite level = CCMenuItemSprite.itemFromNormalSprite(
                        CCSprite.spriteWithSpriteFrameName("btn_level1.png"),
                        CCSprite.spriteWithSpriteFrameName("btn_level2.png"),
                        this, click_level);
                    CCMenu menu = CCMenu.menuWithItems(level);
                    //位置相对于左上的UI界面
                    menu.position = CCDirector.sharedDirector().convertToUI(new CCPoint(offset.x + 160 * i, offset.y + 85 * j));
                    this.addChild(menu);
                    //创建一个MenuItem,用作文本内容
                    CCMenuItem menuitem = new CCMenuItem();
                    //指定Arial的字体描述,保证fonts里有Arial.spritefont
                    var text = CCLabelTTF.labelWithString((j * 4 + i + 1).ToString(), "Arial", 12);
                    //将颜色指定为黑色
                    text.Color = new ccColor3B();
                    menuitem.addChild(text);
                    menu.addChild(menuitem);
                }
            }
        }
示例#2
0
        public override void onEnter()
        {
            base.onEnter();
            m_grossini = CCSprite.spriteWithFile(TestResource.s_pPathGrossini);
            m_tamara   = CCSprite.spriteWithFile(TestResource.s_pPathSister1);
            m_kathia   = CCSprite.spriteWithFile(TestResource.s_pPathSister2);

            addChild(m_grossini, 3);
            addChild(m_kathia, 2);
            addChild(m_tamara, 1);

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

            m_grossini.position = new CCPoint(60, 50);
            m_kathia.position   = new CCPoint(60, 150);
            m_tamara.position   = new CCPoint(60, 250);

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

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

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

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

            menu.position  = CCPoint.Zero;
            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);
        }
示例#3
0
        public TileDemo()
        {
            base.isTouchEnabled = true;

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

            m_label = CCLabelTTF.labelWithString("not", "Arial", 28);
            addChild(m_label, 1);
            m_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);

                m_subtitle = l;
            }

            CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage(s_pPathB1, s_pPathB2, this, backCallback);
            CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage(s_pPathR1, s_pPathR2, this, restartCallback);
            CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage(s_pPathF1, s_pPathF2, this, 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);

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

            menu.position = new CCPoint(0, 0);
            addChild(menu, 1);
        }
        private void AddLabel()
        {
            CCLabelTTF pLabel = CCLabelTTF.labelWithString("Images\\Hello World", "Arial", 24);

            pLabel.position = new CCPoint(size.width / 2, size.height - 50);
            this.addChild(pLabel, 1);
        }
示例#5
0
        public override void onEnter()
        {
            base.onEnter();

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

            CCLabelTTF label = CCLabelTTF.labelWithString(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 = CCLabelTTF.labelWithString(subtitle_, "Arial", 16);
                addChild(l, 1);
                l.position = (new CCPoint(s.width / 2, s.height - 80));
            }

            CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage(s_pPathB1, s_pPathB2, this, (backCallback));
            CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage(s_pPathR1, s_pPathR2, this, (restartCallback));
            CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage(s_pPathF1, s_pPathF2, 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);
        }
示例#6
0
        public override void onEnter()
        {
            base.onEnter();

            CCTextureCache.sharedTextureCache().dumpCachedTextureInfo();
            CCSize     s     = CCDirector.sharedDirector().getWinSize();
            CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 26);

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

            string strSubtitle = subtitle();

            if (strSubtitle.Length > 0)
            {
                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(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);
            CCTextureCache.sharedTextureCache().dumpCachedTextureInfo();
        }
示例#7
0
        public override void onEnter()
        {
            //
            // This test MUST be done in 'onEnter' and not on 'init'
            // otherwise the paused action will be resumed at 'onEnter' time
            //
            base.onEnter();

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

            CCLabelTTF l = CCLabelTTF.labelWithString("After 5 seconds grossini should move", "Arial", 16);

            addChild(l);
            l.position = (new CCPoint(s.width / 2, 245));


            //
            // Also, this test MUST be done, after [super onEnter]
            //
            CCSprite grossini = CCSprite.spriteWithFile(s_pPathGrossini);

            addChild(grossini, 0, kTagGrossini);
            grossini.position = (new CCPoint(200, 200));

            CCAction action = CCMoveBy.actionWithDuration(1, new CCPoint(150, 0));

            CCActionManager.sharedManager().addAction(action, grossini, true);

            schedule(unpause, 3);
        }
示例#8
0
        private void CreateQuestionLanguage(CCMenu p_Menu)
        {
            CCLabelTTF label = CCLabelTTF.labelWithString("发音", "ChineseTitle", 28);

            label.Color = new ccColor3B(Color.White);
            CCMenuItemLabel tab = CCMenuItemLabel.itemWithLabel(label);
        }
示例#9
0
        /// <summary>
        /// 菜单初始化
        /// </summary>
        private void MenuInit()
        {
            CCLabelTTF startlabel    = CCLabelTTF.labelWithString("开始", "ChineseTitle", 28);
            CCLabelTTF settinglabel  = CCLabelTTF.labelWithString("选项", "ChineseTitle", 28);
            CCLabelTTF listwordlabel = CCLabelTTF.labelWithString("词库列表", "ChineseTitle", 28);
            CCLabelTTF addwordlabel  = CCLabelTTF.labelWithString("添加词", "ChineseTitle", 28);
            CCLabelTTF endlabel      = CCLabelTTF.labelWithString("结束", "ChineseTitle", 28);

            CCMenuItemLabel startbutton   = CCMenuItemLabel.itemWithLabel(startlabel, this, this.StartCallback);
            CCMenuItemLabel settingbutton = CCMenuItemLabel.itemWithLabel(settinglabel, this, this.SettingCallback);
            CCMenuItemLabel managebutton  = CCMenuItemLabel.itemWithLabel(listwordlabel, this, this.WordListClick);
            CCMenuItemLabel addwordbutton = CCMenuItemLabel.itemWithLabel(addwordlabel, this, this.WordAddClick);
            CCMenuItemLabel endbutton     = CCMenuItemLabel.itemWithLabel(endlabel, this, this.closeCallback);

            startbutton.Color   = new ccColor3B(Color.Black);
            settingbutton.Color = new ccColor3B(Color.Black);
            managebutton.Color  = new ccColor3B(Color.Black);
            endbutton.Color     = new ccColor3B(Color.Black);
            addwordbutton.Color = new ccColor3B(Color.Black);

            CCMenu menu = CCMenu.menuWithItems(startbutton, settingbutton, managebutton, addwordbutton, endbutton);

            menu.alignItemsInColumns(1, 1, 1, 1, 1);
            addChild(menu, 1);
        }
        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 (!string.IsNullOrEmpty(strSubtitle))
            {
                CCLabelTTF l = CCLabelTTF.labelWithString(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 = CCMenuItemImage.itemFromNormalImage("Images/b1", "Images/b2", this, backCallback);
            CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage("Images/r1", "Images/r2", this, restartCallback);
            CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage("Images/f1", "Images/f2", this, 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);
        }
示例#11
0
        public override void onEnter()
        {
            base.onEnter();

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

            // Title
            CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 40);

            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 = CCLabelTTF.labelWithString(strSubTitle, "Thonburi", 16);
                addChild(l, 1);
                l.position = new CCPoint(s.width / 2, s.height - 80);
            }

            performTests();
        }
        public override void onEnter()
        {
            base.onEnter();

            float x, y;

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

            x = size.width;
            y = size.height;

            CCSprite bg = CCSprite.spriteWithFile("Images/background3");

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

            grossini = CCSprite.spriteWithFile("Images/grossinis_sister2");
            bg.addChild(grossini, 1, EffectAdvanceScene.kTagSprite1);
            grossini.position = new CCPoint(x / 3.0f, 200);
            CCActionInterval   sc      = CCScaleBy.actionWithDuration(2, 5);
            CCFiniteTimeAction sc_back = sc.reverse();

            grossini.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(sc, sc_back))));

            tamara = CCSprite.spriteWithFile("Images/grossinis_sister1");
            bg.addChild(tamara, 1, EffectAdvanceScene.kTagSprite2);
            tamara.position = new CCPoint(2 * x / 3.0f, 200);
            CCActionInterval   sc2      = CCScaleBy.actionWithDuration(2, 5);
            CCFiniteTimeAction sc2_back = sc2.reverse();

            tamara.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(sc2, sc2_back))));

            CCLabelTTF label = CCLabelTTF.labelWithString(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 = CCLabelTTF.labelWithString(strSubtitle, "Arial", 16);
                addChild(l, 101);
                l.position = new CCPoint(size.width / 2, size.height - 80);
            }

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

            CCMenu menu = CCMenu.menuWithItems(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);
        }
示例#13
0
        /// <summary>
        /// add chinese input item
        /// </summary>
        private void AddEnglishItem()
        {
            CCMenuItemImage image = LoadTextBoxSprite();

            CCLabelTTF text = CCLabelTTF.labelWithString("英文", "ChineseTitle", 28);

            text.Color = new ccColor3B(Color.Black);
            CCMenuItemLabel label = CCMenuItemLabel.itemWithLabel(text);

            m_EnglishLabel       = CreateTextLabel(Language.Enlish, String.Empty);
            m_EnglishLabel.Color = new ccColor3B(Color.Black);
            CCMenuItemLabel content = CCMenuItemLabel.itemWithLabel(m_EnglishLabel);

            content.position = new CCPoint(10, 0);
            image.addChild(content);

            CCMenu menu = CCMenu.menuWithItems(label, image);

            menu.alignItemsHorizontallyWithPadding(50);
            menu.position = new CCPoint(240, m_CurrPostion.y);
            addChild(menu);

            m_CurrPostion.y -= image.contentSize.height;
            m_CurrPostion.y -= StillWhite;
        }
        public override void onEnter()
        {
            base.onEnter();

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

            CCLabelTTF label = CCLabelTTF.labelWithString(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 = 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(this.backCallback));
            CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathR1, TestResource.s_pPathR2, this, new SEL_MenuHandler(this.restartCallback));
            CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathF1, TestResource.s_pPathF2, this, new SEL_MenuHandler(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);
        }
示例#15
0
        /// <summary>
        /// add submit and cancel button
        /// </summary>
        private void AddFormButton()
        {
            CCMenuItemImage imagesubmit = CCMenuItemImage.itemFromNormalImage("image/ButtonNormal", "image/ButtonClick", this, AddImageClick);
            CCLabelTTF      textsubmit  = CCLabelTTF.labelWithString("确定", "ChineseContent", 28);

            textsubmit.Color = new ccColor3B(Color.Black);
            CCMenuItemLabel labelsubmit = CCMenuItemLabel.itemWithLabel(textsubmit);

            labelsubmit.position = new CCPoint(imagesubmit.contentSize.width / 2, imagesubmit.contentSize.height / 2);
            imagesubmit.addChild(labelsubmit);

            CCMenuItemImage imagecancel = CCMenuItemImage.itemFromNormalImage("image/ButtonNormal", "image/ButtonClick", this, AddImageClick);
            CCLabelTTF      textcancel  = CCLabelTTF.labelWithString("取消", "ChineseContent", 28);

            textcancel.Color = new ccColor3B(Color.Black);
            CCMenuItemLabel labelcancel = CCMenuItemLabel.itemWithLabel(textcancel);

            labelcancel.position = new CCPoint(imagecancel.contentSize.width / 2, imagecancel.contentSize.height / 2);

            imagecancel.addChild(labelcancel);


            CCMenu menu = CCMenu.menuWithItems(imagesubmit, imagecancel);

            menu.alignItemsHorizontally();
            menu.position = new CCPoint(240, m_CurrPostion.y);
            addChild(menu);

            m_CurrPostion.y -= imagesubmit.contentSize.height;
            m_CurrPostion.y -= StillWhite;
        }
示例#16
0
        public LabelsEmpty()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            // CCLabelBMFont
            CCLabelBMFont label1 = CCLabelBMFont.labelWithString("", "fonts/fnt/bitmapFontTest3");

            addChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1);
            label1.position = new CCPoint(s.width / 2, s.height - 100);

            // CCLabelTTF
            CCLabelTTF label2 = CCLabelTTF.labelWithString("", "Arial", 24);

            addChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);
            label2.position = new CCPoint(s.width / 2, s.height / 2);

            // CCLabelAtlas
            CCLabelAtlas label3 = CCLabelAtlas.labelWithString("", "fonts/fnt/images/tuffy_bold_italic-charmap", 48, 64, ' ');

            addChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3);
            label3.position = new CCPoint(s.width / 2, 0 + 100);

            base.schedule(updateStrings, 1.0f);

            setEmpty = false;
        }
示例#17
0
        public override bool init()
        {
            if (base.init())
            {
                CCSize s = CCDirector.sharedDirector().getWinSize();

                CCLayerColor background = CCLayerColor.layerWithColor(new ccColor4B(255, 0, 255, 255));
                addChild(background);

                CCLayerColor sprite_a = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(255, 0, 0, 255), 700, 700);
                sprite_a.anchorPoint           = new CCPoint(0.5f, 0.5f);
                sprite_a.isRelativeAnchorPoint = true;
                sprite_a.position = new CCPoint(0.0f, s.height / 2);
                addChild(sprite_a);

                sprite_a.runAction(CCRepeatForever.actionWithAction((CCActionInterval)CCSequence.actions(
                                                                        CCMoveTo.actionWithDuration(1.0f, new CCPoint(1024.0f, 384.0f)),
                                                                        CCMoveTo.actionWithDuration(1.0f, new CCPoint(0.0f, 384.0f)))));

                CCLayerColor sprite_b = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(0, 0, 255, 255), 400, 400);
                sprite_b.anchorPoint           = new CCPoint(0.5f, 0.5f);
                sprite_b.isRelativeAnchorPoint = true;
                sprite_b.position = new CCPoint(s.width / 2, s.height / 2);
                addChild(sprite_b);

                CCMenuItemLabel label = CCMenuItemLabel.itemWithLabel(CCLabelTTF.labelWithString("Flip Me", "Helvetica", 24), this, callBack);
                CCMenu          menu  = CCMenu.menuWithItems(label);
                menu.position = new CCPoint(s.width - 200.0f, 50.0f);
                addChild(menu);

                return(true);
            }

            return(false);
        }
示例#18
0
        public ParticleDemo()
        {
            initWithColor(ccTypes.ccc4(127, 127, 127, 255));

            m_emitter = null;

            isTouchEnabled = true;

            CCSize     s     = CCDirector.sharedDirector().getWinSize();
            CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 28);

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

            CCLabelTTF tapScreen = CCLabelTTF.labelWithString("(Tap the Screen)", "Arial", 20);

            tapScreen.position = new CCPoint(s.width / 2, s.height - 80);
            addChild(tapScreen, 100);

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

            CCMenuItemToggle item4 = CCMenuItemToggle.itemWithTarget(this,
                                                                     new SEL_MenuHandler(toggleCallback),
                                                                     CCMenuItemFont.itemFromString("Free Movement"),
                                                                     CCMenuItemFont.itemFromString("Relative Movement"),
                                                                     CCMenuItemFont.itemFromString("Grouped Movement"));

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

            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);
            item4.position    = new CCPoint(0, 100);
            item4.anchorPoint = new CCPoint(0, 0);

            addChild(menu, 100);

            CCLabelAtlas labelAtlas = CCLabelAtlas.labelWithString("0000", "fonts/fnt/images/fps_images", 16, 24, '.');

            addChild(labelAtlas, 100, ParticleTestScene.kTagLabelAtlas);
            labelAtlas.position = new CCPoint(s.width - 66, 50);

            // moving background
            m_background = CCSprite.spriteWithFile(TestResource.s_back3);
            addChild(m_background, 5);
            m_background.position = new CCPoint(s.width / 2 - 120, s.height - 240);

            CCActionInterval   move      = CCMoveBy.actionWithDuration(4, new CCPoint(300, 0));
            CCFiniteTimeAction move_back = move.reverse();
            CCFiniteTimeAction seq       = CCSequence.actions(move, move_back);

            m_background.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq));


            schedule(new SEL_SCHEDULE(step));
        }
        public LabelTTFChinese()
        {
            CCSize     size   = CCDirector.sharedDirector().getWinSize();
            CCLabelTTF pLable = CCLabelTTF.labelWithString("Chinaese", "Arial", 30);

            pLable.position = new CCPoint(size.width / 2, size.height / 2);
            addChild(pLable);
        }
示例#20
0
        public void callback3(CCNode pTarget, object data)
        {
            CCSize     s     = CCDirector.sharedDirector().getWinSize();
            CCLabelTTF label = CCLabelTTF.labelWithString("callback 3 called", "Arial", 16);

            label.position = new CCPoint(s.width / 4 * 3, s.height / 2);
            addChild(label);
        }
        public override bool init()
        {
            // always call "super" init
            // Apple recommends to re-assign "self" with the "super" return value
            if (base.init())
            {
                isTouchEnabled = true;
                // ask director the the window size
                CCSize       size = CCDirector.sharedDirector().getWinSize();
                CCLayerColor layer;
                CCUserDefault.sharedUserDefault().setBoolForKey("bool", true);
                for (int i = 0; i < 5; i++)
                {
                    ccColor4B c = new ccColor4B((byte)(i * 20), (byte)(i * 20), (byte)(i * 20), 255);
                    CCUserDefault.sharedUserDefault().setStringForKey("i" + i, c.ToString());
                }
                CCUserDefault.sharedUserDefault().flush();
                bool testValue = CCUserDefault.sharedUserDefault().getBoolForKey("bool", false);
                if (!testValue)
                {
                    CCLog.Log("CCUserDefault: Test failed b/c the 'bool' value was not true when it was expected.");
                }
                for (int i = 0; i < 5; i++)
                {
                    string cstr = CCUserDefault.sharedUserDefault().getStringForKey("i" + i, null);
                    if (cstr == null)
                    {
                        CCLog.Log("CCUserDefault: The color for iteration #" + i + " is null.");
                        continue;
                    }
                    ccColor4B c = new ccColor4B((byte)(i * 20), (byte)(i * 20), (byte)(i * 20), 255);
                    layer                       = CCLayerColor.layerWithColor(c);
                    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.isRelativeAnchorPoint = true;
                    addChild(layer, -1 - i);
                }

                // create and initialize a Label
                CCLabelTTF label = CCLabelTTF.labelWithString("ccUserDefault Test", "Arial", 14);
                CCMenuItem item1 = CCMenuItemFont.itemFromString("restart", this, restart);

                CCMenu menu = CCMenu.menuWithItems(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);
        }
示例#22
0
        /// <summary>
        ///  Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
        /// </summary>
        public override bool init()
        {
            CCDirector.sharedDirector().deviceOrientation = ccDeviceOrientation.CCDeviceOrientationLandscapeLeft;

            //////////////////////////////
            // 1. super init first
            if (!base.init())
            {
                return(false);
            }

            this.m_bIsTouchEnabled = true;
            /////////////////////////////
            // 2. add a menu item with "X" image, which is clicked to quit the program
            //    you may modify it.

            // add a "close" icon to exit the progress. it's an autorelease object
            CCMenuItemImage pCloseItem = CCMenuItemImage.itemFromNormalImage(
                "CloseNormal",
                "CloseSelected",
                this,
                new SEL_MenuHandler(menuCloseCallback));

            pCloseItem.position = new CCPoint(CCDirector.sharedDirector().getWinSize().width - 20, 20);

            // create menu, it's an autorelease object
            CCMenu pMenu = CCMenu.menuWithItems(pCloseItem);

            pMenu.position = new CCPoint(0, 0);
            this.addChild(pMenu, 1);

            /////////////////////////////
            // 3. add your codes below...

            // add a label shows "Hello World"
            // create and initialize a label
            CCLabelTTF pLabel = CCLabelTTF.labelWithString("Hello World", "Arial", 24);
            // ask director the window size
            CCSize size = CCDirector.sharedDirector().getWinSize();

            // position the label on the center of the screen
            pLabel.position = new CCPoint(size.width / 2, size.height - 50);

            // add the label as a child to this layer
            this.addChild(pLabel, 1);

            // add "HelloWorld" splash screen"
            CCSprite pSprite = CCSprite.spriteWithFile("HelloWorld");

            // position the sprite on the center of the screen
            pSprite.position = new CCPoint(size.width / 2, size.height / 2);

            // add the sprite as a child to this layer
            this.addChild(pSprite, 0);

            return(true);
        }
        public virtual void initWithQuantityOfNodes(int nNodes)
        {
            //srand(time());
            CCSize s = CCDirector.sharedDirector().getWinSize();

            // Title
            CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 40);

            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 = CCLabelTTF.labelWithString(strSubTitle, "Thonburi", 16);
                addChild(l, 1);
                l.position = new CCPoint(s.width / 2, s.height - 80);
            }

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

            CCMenuItemFont.FontSize = 65;
            CCMenuItemFont decrease = CCMenuItemFont.itemFromString(" - ", this, onDecrease);

            decrease.Color = new ccColor3B(0, 200, 20);
            CCMenuItemFont increase = CCMenuItemFont.itemFromString(" + ", this, onIncrease);

            increase.Color = new ccColor3B(0, 200, 20);

            CCMenu menu = CCMenu.menuWithItems(decrease, increase);

            menu.alignItemsHorizontally();
            menu.position = new CCPoint(s.width / 2, s.height / 2 + 15);
            addChild(menu, 1);

            CCLabelTTF infoLabel = CCLabelTTF.labelWithString("0 nodes", "Marker Felt", 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();
        }
示例#24
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 = 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);
        }
示例#25
0
        public LabelTTFMultiline()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            // CCLabelBMFont
            CCLabelTTF center = CCLabelTTF.labelWithString("word wrap \"testing\" (bla0) bla1 'bla2' [bla3] (bla4) {bla5} {bla6} [bla7] (bla8) [bla9] 'bla0' \"bla1\"",
                                                           new CCSize(s.width / 2, 200), CCTextAlignment.CCTextAlignmentCenter, "Arial", 32);

            center.position = new CCPoint(s.width / 2, 150);

            addChild(center);
        }
示例#26
0
        private CCLabelTTF CreateTextLabel(Language p_Language, String p_Text)
        {
            switch (p_Language)
            {
            case Language.Chinese:
                return(CCLabelTTF.labelWithString(p_Text, "ChineseContent", 28));

            case Language.Enlish:
            default:
                return(CCLabelTTF.labelWithString(p_Text, "EnglishContent", 28));
            }
        }
示例#27
0
        public override void onEnter()
        {
            base.onEnter();

            // Or you can create an sprite using a filename. only PNG is supported now. Probably TIFF too
            m_grossini = CCSprite.spriteWithFile(TestResource.s_pPathGrossini);

            m_tamara = CCSprite.spriteWithFile(TestResource.s_pPathSister1);

            m_kathia = CCSprite.spriteWithFile(TestResource.s_pPathSister2);

            addChild(m_grossini, 1);
            addChild(m_tamara, 2);
            addChild(m_kathia, 3);

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

            m_grossini.position = new CCPoint(s.width / 2, s.height / 3);
            m_tamara.position   = new CCPoint(s.width / 2, 2 * s.height / 3);
            m_kathia.position   = new CCPoint(s.width / 2, s.height / 2);

            // add title and subtitle
            string     str    = title();
            string     pTitle = str;
            CCLabelTTF label  = CCLabelTTF.labelWithString(pTitle, "Arial", 18);

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

            string strSubtitle = subtitle();

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

            // add menu
            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(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);
        }
        public Button(string label, CCNode parent, ButtonClickDelegate d)
        {
            _label   = label;
            _parent  = parent;
            _onClick = d;

            CCLabelTTF      ttf   = CCLabelTTF.labelWithString(label, "Arial", 32f);
            CCMenuItemLabel item  = CCMenuItemLabel.itemWithLabel(ttf, null, new SEL_MenuHandler(d));
            CCMenu          pMenu = CCMenu.menuWithItems(item);

            pMenu.position = new CCPoint(0, 0);
            addChild(pMenu);
        }
        /// <summary>
        /// AddTitleMenu only text
        /// </summary>
        /// <param name="p_Layer">current CCLayer</param>
        /// <param name="p_TitleText">show text</param>
        /// <param name="y">current y</param>
        public static void AddTitleMenu(CCLayer p_Layer, String p_TitleText, ref float y)
        {
            CCLabelTTF label = CCLabelTTF.labelWithString(p_TitleText, "ChineseTitle", 28);

            label.Color = new ccColor3B(Color.White);

            CCMenuItemLabel tab  = CCMenuItemLabel.itemWithLabel(label);
            CCMenu          menu = CCMenu.menuWithItems(tab);

            menu.position = new CCPoint(CCDirector.sharedDirector().displaySizeInPixels.width / 2, y);
            //menu.position.y = p_CurrPoint.y;

            y -= tab.contentSize.height + Blank;
            p_Layer.addChild(menu);
        }
示例#30
0
        /// <summary>
        /// add "select image" button
        /// </summary>
        private void AddImageButton()
        {
            CCMenuItemImage image = CCMenuItemImage.itemFromNormalImage("image/ButtonNormal", "image/ButtonClick", this, AddImageClick);
            CCLabelTTF      text  = CCLabelTTF.labelWithString("选择图片", "ChineseContent", 28);

            text.Color = new ccColor3B(Color.Black);
            CCMenuItemLabel label = CCMenuItemLabel.itemWithLabel(text);

            CCMenu menu = CCMenu.menuWithItems(image, label);

            menu.position = new CCPoint(240, m_CurrPostion.y);
            addChild(menu);

            m_CurrPostion.y -= image.contentSize.height;
            m_CurrPostion.y -= StillWhite;
        }