Esempio n. 1
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);
        }
Esempio n. 2
0
        public LabelsEmpty()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

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

            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/tuffy_bold_italic-charmap.png", 48, 64, ' ');

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

            base.schedule(updateStrings, 1.0f);

            setEmpty = false;
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public bool initFromString(string value, SelectorProtocol target, SEL_MenuHandler selector)
        {
            this.m_strFontName = CCMenuItem._fontName;
            this.m_uFontSize   = CCMenuItem._fontSize;
            CCLabelTTF cCLabelTTF = CCLabelTTF.labelWithString(value, this.m_strFontName, (float)((float)this.m_uFontSize));

            base.initWithLabel(cCLabelTTF, target, selector);
            return(true);
        }
Esempio n. 5
0
        public virtual bool onTextFieldInsertText(CCTextFieldTTF pSender, string text, int nLen)
        {
            // if insert enter, treat as default to detach with ime
            if ("\n" == text)
            {
                return(false);
            }

            // if the textfield's char count more than m_nCharLimit, doesn't insert text anymore.
            if (pSender.CharCount >= m_nCharLimit)
            {
                return(true);
            }

            // create a insert text sprite and do some action
            CCLabelTTF label = CCLabelTTF.labelWithString(text, TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);

            this.addChild(label);
            ccColor3B color = new ccColor3B {
                r = 226, g = 121, b = 7
            };

            label.Color = color;

            // move the sprite from top to position
            CCPoint endPos = pSender.position;

            if (pSender.CharCount > 0)
            {
                endPos.x += pSender.contentSize.width / 2;
            }
            CCSize  inputTextSize = label.contentSize;
            CCPoint beginPos      = new CCPoint(endPos.x, CCDirector.sharedDirector().getWinSize().height - inputTextSize.height * 2);

            float duration = 0.5f;

            label.position = beginPos;
            label.scale    = 8;

            CCAction seq = CCSequence.actions(
                CCSpawn.actions(
                    CCMoveTo.actionWithDuration(duration, endPos),
                    CCScaleTo.actionWithDuration(duration, 1),
                    CCFadeOut.actionWithDuration(duration)),
                CCCallFuncN.actionWithTarget(this, callbackRemoveNodeWhenDidAction));

            label.runAction(seq);
            return(false);
        }
Esempio n. 6
0
        /** initializes a menu item from a string with a target/selector */
        public bool initFromString(string value, SelectorProtocol target, SEL_MenuHandler selector)
        {
            //CCAssert( value != NULL && strlen(value) != 0, "Value length must be greater than 0");

            m_strFontName = _fontName;
            m_uFontSize   = _fontSize;

            CCLabelTTF label = CCLabelTTF.labelWithString(value, m_strFontName, (float)m_uFontSize);

            if (base.initWithLabel(label, target, selector))
            {
                // do something ?
            }

            return(true);
        }
Esempio n. 7
0
        public virtual bool onTextFieldDeleteBackward(CCTextFieldTTF pSender, string delText, int nLen)
        {
            // create a delete text sprite and do some action
            CCLabelTTF label = CCLabelTTF.labelWithString(delText, TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);

            this.addChild(label);

            // move the sprite to fly out
            CCPoint beginPos      = pSender.position;
            CCSize  textfieldSize = pSender.contentSize;
            CCSize  labelSize     = label.contentSize;

            beginPos.x += (textfieldSize.width - labelSize.width) / 2.0f;

            int    RAND_MAX = 32767;
            Random rand     = new Random();

            CCSize  winSize        = CCDirector.sharedDirector().getWinSize();
            CCPoint endPos         = new CCPoint(-winSize.width / 4.0f, winSize.height * (0.5f + (float)rand.Next() / (2.0f * RAND_MAX)));
            float   duration       = 1;
            float   rotateDuration = 0.2f;
            int     repeatTime     = 5;

            label.position = beginPos;

            CCAction seq = CCSequence.actions(
                CCSpawn.actions(
                    CCMoveTo.actionWithDuration(duration, endPos),
                    CCRepeat.actionWithAction(
                        CCRotateBy.actionWithDuration(rotateDuration, (rand.Next() % 2 > 0) ? 360 : -360),
                        (uint)repeatTime),
                    CCFadeOut.actionWithDuration(duration)),
                CCCallFuncN.actionWithTarget(this, callbackRemoveNodeWhenDidAction));

            label.runAction(seq);
            return(false);
        }