//// HelloWorldScene.h//#ifndef __HELLOWORLD_SCENE_H__#define __HELLOWORLD_SCENE_H__#include "cocos2d.h"USING_NS_CC;class HelloWorld : public cocos2d::cclayer,public cocos2d::CCTextFIEldDelegate{public: virtual bool init(); static cocos2d::CCScene* scene(); voID menuCloseCallback(CCObject* pSender); CREATE_FUNC(HelloWorld); virtual bool onTextFIEldAttachWithIME(CCTextFIEldTTF *pSender); virtual bool onTextFIEldDetachWithIME(CCTextFIEldTTF *pSender); virtual bool onTextFIEldInsertText(CCTextFIEldTTF *pSender,const char *delText,int nLen); virtual bool onTextFIEldDeleteBackward(CCTextFIEldTTF *pSender,int nLen);};#endif
<pre name="code" >//// HelloWorldScene.h//#include "HelloWorldScene.h"USING_NS_CC;CCScene* HelloWorld::scene(){ CCScene *scene = CCScene::create(); HelloWorld *layer = HelloWorld::create(); scene->addChild(layer); return scene;}bool HelloWorld::init(){ if ( !cclayer::init() ) { return false; } CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); CCTextFIEldTTF *textFIEld = CCTextFIEldTTF::textFIElDWithPlaceHolder("点击输入...","Helvetica",24); textFIEld->setposition(ccp(visibleSize.wIDth*0.5,visibleSize.height*0.7)); textFIEld->setDelegate(this); textFIEld->attachWithIME(); this->addChild(textFIEld); return true;}// CCTextFIEldTTFDelegatebool HelloWorld::onTextFIEldAttachWithIME(CCTextFIEldTTF *pSender){ cclog("启动输入"); return false;}bool HelloWorld::onTextFIEldDetachWithIME(CCTextFIEldTTF *pSender){ cclog("关闭输入"); return false;}bool HelloWorld::onTextFIEldInsertText(CCTextFIEldTTF *pSender,const char *text,int nLen){ cclog("输入字符"); return false;}bool HelloWorld::onTextFIEldDeleteBackward(CCTextFIEldTTF *pSender,int nLen){ cclog("删除字符"); return false;}总结
以上是内存溢出为你收集整理的Cocos2d-x_CCTextFieldTTF输入框全部内容,希望文章能够帮你解决Cocos2d-x_CCTextFieldTTF输入框所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)