Text input
Cctextfiledttf
Cctextfiledttf * textedit = cctextfiledttf: textfiledwithzaceholder ("input", "Arial", 33 );
Textedit-> atchwithime (); the keyboard is displayed.
Textedit-> setsecuretextentry (true); password format input
Cceditbox
Ccscale9sprite * BG = ccscale9sprite: Create ("abc.png"); 9 Mei map is easy to expand, saving resources
Cceditbox * editbox = cceditbox: Create (ccsize (100, 30), BG );
Editbox-> setplaceholder ("input here"); displays text by default
Editbox-> setinputflag (...); in various cases, such as uppercase letters and Case sensitivity.
Menu
Ccmenuitemfont * Item = ccmenuitemfont: Create ("this is item"); the default location is in the center
Menu-> addchid (item );
Ccmenu * menu = ccmenu: Create ();
Addchild (menu );
Set the corresponding function
Item-> settarget (this, menu_selector (function pointer ));
Void menu: menuhandler (cccobject *)
{
}
Menuitems
Ccmenuitematlasfont * itemaltas = ccmenuitematlasfont: Create ("123456", "labelatlasimg.png", 24, 32, '0 ');
Ccmenuitemimage * itemimage = ccmenuitemimaage: Create ("closenormal.png", "closesected.png ");
Ccmenuitemlabel * itemlabel = ccmenuitemlabel: Create (
Cclabelttf: Create ("this is lable TTF item", "Arial", 33 );
);
Ccmenuitemlabel * itemlableibmfont = ccmenuitemlabel: Create ();
Ccmenuitemtoggle * itemtoggle = ccmenuitemtoggle: createwithtarget ();
Vertical Alignment
Menu-> alignitemsvertically ();
Cocos Memory Management
C ++ constructor is language-Level Initialization
Init is the initialization of the Cocos service layer.
Coocs uses semi-automated Memory Management
Create () = Automatic Management
Memory Manager-> Access Reference Counter
New
Release ()
Retain () reference counter plus 1
Autorelease adds this object to the Memory Manager
Cocos semi-automatic memory management is implemented by ccobject
Counter
Counter setting function
For retain () objects, to avoid Memory leakage
Two methods can be used: release ();
~ Destructor ()
{
_ Arr-> release ();
}
Void onexit ()
{
Parent class: onexit (); The onexit () function of the parent class must be called first; otherwise, larger memory leakage will occur.
_ Arr-> release ();
}
Scheduleupdate (); let the frame call this-> Update (float DT) function cyclically
Void helloworld: handeer (ccobject * sender)
{
Ccnode * node = (ccnode *) sender;
Haha = node-> gettag ()-1000;
}
Void helloworld: Update (float delta)
{
If (1 = haha)
{
SP-> setpositiony (SP-> getpositiony () + 150 * delta );
Cclog ("1 ");
}
If (2 = haha)
{
SP-> setpositiony (SP-> getpositiony ()-150 * delta );
Cclog ("2 ");
}
If (3 = haha)
{
SP-> setpositionx (SP-> getpositionx ()-150 * delta );
Cclog ("3 ");
}
If (4 = haha)
{
SP-> setpositionx (SP-> getpositionx () + 150 * delta );
Cclog ("4 ");
}
Return;
}
[Cocos2d-x Study Notes] text input, menu, memory management, Timer