Esempio n. 1
0
        public LabelTTFA8Test()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

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

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

            CCFadeOut fadeOut = new CCFadeOut  (2);
            CCFadeIn fadeIn = new CCFadeIn  (2);
            CCFiniteTimeAction seq = CCSequence.FromActions(fadeOut, fadeIn);
            CCRepeatForever forever = new CCRepeatForever ((CCActionInterval) seq);
            label1.RunAction(forever);
        }
Esempio n. 2
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 = new CCLabelTTF(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.WinSize.Height - inputTextSize.Height * 2);

            float duration = 0.5f;
            label.Position = beginPos;
            label.Scale = 8;

            CCAction seq = CCSequence.FromActions(
                CCSpawn.FromActions(
                    new CCMoveTo (duration, endPos),
                    new CCScaleTo(duration, 1),
                    new CCFadeOut  (duration)),
                new CCCallFuncN(callbackRemoveNodeWhenDidAction));
            label.RunAction(seq);
            return false;
        }
Esempio n. 3
0
        public virtual bool onTextFieldDeleteBackward(CCTextFieldTTF pSender, string delText, int nLen)
        {
            // create a delete text sprite and do some action
            CCLabelTTF label = new CCLabelTTF(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.WinSize;
            CCPoint endPos = new CCPoint(-winSize.Width / 4.0f, winSize.Height * (0.5f + (float)Random.Next() / (2.0f * RAND_MAX)));
            float duration = 1;
            float rotateDuration = 0.2f;
            int repeatTime = 5;
            label.Position = beginPos;

            CCAction seq = CCSequence.FromActions(
                CCSpawn.FromActions(
                    new CCMoveTo (duration, endPos),
                    new CCRepeat (
                        new CCRotateBy (rotateDuration, (Random.Next() % 2 > 0) ? 360 : -360),
                        (uint)repeatTime),
                    new CCFadeOut  (duration)),
                new CCCallFuncN(callbackRemoveNodeWhenDidAction));
            label.RunAction(seq);
            return false;
        }
Esempio n. 4
0
        internal void ShowBoardMessage(string theMessage)
        {
            CCLabelTTF boardMessage = new CCLabelTTF(theMessage, "MarkerFelt", 22);
            AddChild(boardMessage, Constants.DepthPointScore);
            boardMessage.Color = new CCColor3B(255,255,255);
            boardMessage.PositionX = screenWidth /2;
            boardMessage.PositionY = screenHeight * .7f;

            CCSequence seq = CCSequence.FromActions(
                               new CCScaleTo(2.0f, 2.0f),
                               new CCFadeTo(1.0f, 0),
                               new CCCallFuncN(RemoveBoardMessage)  //NOTE: CCCallFuncN  works, CCCallFunc does not.
                );

            boardMessage.RunAction(seq);
        }
Esempio n. 5
0
        void ShowPointsWithFontLabelForValue(int pointValue, CCPoint positionToShowScore)
        {
            CCLabelTTF scoreLabel = new CCLabelTTF(string.Format("{0}", pointValue), "MarkerFelt", 22);
            AddChild(scoreLabel, Constants.DepthPointScore);
            scoreLabel.Color = new CCColor3B(255,255,255);
            scoreLabel.Position = positionToShowScore;

            CCMoveTo moveAction = new CCMoveTo(1.0f, new CCPoint ( scoreLabel.Position.X  , scoreLabel.Position.Y + 25 ));

            scoreLabel.RunAction(moveAction);

            CCSequence seq = CCSequence.FromActions(
                new CCFadeTo(1.5f, 20),
                new CCCallFuncN(RemoveThisLabel));

            scoreLabel.RunAction(seq);
        }