// CCTextFieldDelegate public virtual bool onTextFieldAttachWithIME(CCTextFieldTTF pSender) { // if (m_bAction != null) // { // m_pTextField.RunAction(m_pTextFieldAction); // m_bAction = true; // } return(false); }
public virtual bool onTextFieldDetachWithIME(CCTextFieldTTF pSender) { // if (m_bAction != null) // { // m_pTextField.StopAction(m_pTextFieldAction); // m_pTextField.Opacity = 255; // m_bAction = false; // } 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.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); }
public override void OnEnter() { base.OnEnter(); var s = Layer.VisibleBoundsWorldspace.Size; var pTextField = new CCTextFieldTTF( "<click here for input>", TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE ); pTextField.Position = Layer.VisibleBoundsWorldspace.Size.Center; pTextField.AutoEdit = true; AddChild(pTextField); //m_pTrackNode = pTextField; }
// CCLayer public override void OnEnter() { base.OnEnter(); m_nCharLimit = 12; m_pTextFieldAction = new CCRepeatForever( (CCFiniteTimeAction) new CCSequence( new CCFadeOut(0.25f), new CCFadeIn(0.25f))); //m_pTextFieldAction->retain(); m_bAction = false; // add CCTextFieldTTF CCSize s = Layer.VisibleBoundsWorldspace.Size; m_pTextField = new CCTextFieldTTF("<click here for input>", TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE); AddChild(m_pTextField); m_pTrackNode = m_pTextField; }
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); }
public virtual bool onDraw(CCTextFieldTTF pSender) { return(false); }