コード例 #1
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.Text.Length >= 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.Text.Length > 0)
            {
                endPos.X += pSender.ContentSize.Width / 2;
            }
            CCSize  inputTextSize = label.ContentSize;
            CCPoint beginPos      = new CCPoint(endPos.X, Layer.VisibleBoundsWorldspace.Size.Height - inputTextSize.Height * 2);

            float duration = 0.5f;

            label.Position = beginPos;
            label.Scale    = 8;

            CCAction seq = new CCSequence(
                new CCSpawn(
                    new CCMoveTo(duration, endPos),
                    new CCScaleTo(duration, 1),
                    new CCFadeOut(duration)),
                new CCCallFuncN(callbackRemoveNodeWhenDidAction));

            label.RunAction(seq);
            return(false);
        }
コード例 #2
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;
            CCRandom rand     = new CCRandom();

            CCSize  winSize        = Layer.VisibleBoundsWorldspace.Size;
            CCPoint endPos         = new CCPoint(-winSize.Width / 4.0f, winSize.Height * (0.5f + (float)CCRandom.Next() / (2.0f * RAND_MAX)));
            float   duration       = 1;
            float   rotateDuration = 0.2f;
            int     repeatTime     = 5;

            label.Position = beginPos;

            CCAction seq = new CCSequence(
                new CCSpawn(
                    new CCMoveTo(duration, endPos),
                    new CCRepeat(
                        new CCRotateBy(rotateDuration, (CCRandom.Next() % 2 > 0) ? 360 : -360),
                        (uint)repeatTime),
                    new CCFadeOut(duration)),
                new CCCallFuncN(callbackRemoveNodeWhenDidAction));

            label.RunAction(seq);
            return(false);
        }
コード例 #3
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 = new CCSequence(
							   new CCScaleTo(2.0f, 2.0f),
							   new CCFadeTo(1.0f, 0),
							   new CCCallFuncN(RemoveBoardMessage)  //NOTE: CCCallFuncN  works, CCCallFunc does not.
				);

			boardMessage.RunAction(seq);


		}
コード例 #4
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 = new CCSequence(
				new CCFadeTo(1.5f, 20),
				new CCCallFuncN(RemoveThisLabel));

			scoreLabel.RunAction(seq);

		}