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); }
public LabelTTFA8Test() { CCSize s = CCDirector.SharedDirector.WinSize; CCLayerColor layer = new CCLayerColor(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 = new CCSequence(fadeOut, fadeIn); CCRepeatForever forever = new CCRepeatForever ((CCActionInterval) seq); label1.RunAction(forever); }
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 = CCDirector.SharedDirector.WinSize; 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 = CCSequence.FromActions( CCSpawn.FromActions( 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); }
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 = CCDirector.SharedDirector.WinSize; 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; }
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 = new CCSequence( new CCSpawn( new CCMoveTo (duration, endPos), new CCScaleTo(duration, 1), new CCFadeOut (duration)), new CCCallFuncN(callbackRemoveNodeWhenDidAction)); label.RunAction(seq); return false; }
public override void OnEnter() { base.OnEnter(); m_nImageOffset = 0; CCSize size = CCDirector.SharedDirector.WinSize; CCLabelTTF label = new CCLabelTTF("Loading...", "Marker Felt", 32); label.Position = size.Center; AddChild(label, 10); CCScaleBy scale = new CCScaleBy(0.3f, 2); CCScaleBy scale_back = (CCScaleBy) scale.Reverse(); CCSequence seq = new CCSequence(scale, scale_back); label.RunAction(new CCRepeatForever(seq)); ScheduleOnce(LoadImages, 1.0f); }
public override void Update(float dt) { base.Update(dt); elapsedTime += dt; if (elapsedTime > 3f) { if (_TheTexture != null) { _TheTexture.XNATexture.Dispose(); _TheTexture = null; } CreateTheButtons(); elapsedTime = 0f; var title = new CCLabelTTF("Refreshing the buttons", "Arial", 30); AddChild(title, 25); title.Position = ContentSize.Center; title.RunAction(new CCFadeOut(1f)); } }
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); }
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); }