ouput

How to use textbox or editbox in cocos2d-x

Hi friends.
In this tutorial I am going to tell you how to use editbox which is like a textbox in cocos2d-x.
There are some simple steps
Step 1:
Step 1 is as simple. Just create a new project in cocos2d-x

Step 2:
Now just remove the extra matter in your HelloWorldScene.h so that it looks like

Step 3:
Add the following in your HelloWorldScene.h

Step 4:
Then we have to add some virtual functions of editbox so that we can override and use them and inherit the HelloWorld class with CCEditBoxDelegate such that now the class looks like

Step 5:
Now make your init function in HelloWorldScene.cpp as

Step 6:
Now we have to redefine the virtual functions. I am not doing anything and leaving them blank. You can set according to their needs

Now you are done. Just run the project. I am attaching my screen shot

Output

Output

By using the

You can store the text in the textbox in string and can use according to your need

Thats all for the text Box.Hope it helps
HAPPY CODING

7,862 total views, 10 views today

Share this OnShare on FacebookTweet about this on TwitterShare on LinkedInShare on Google+

Leave a Reply