Cocos2d-x menu option Button Introduction
To create a menu, the first parameter is an item, a variable parameter, which is equivalent to a mutable parameter in Java
Menuitemimage::create (normal state picture background, selected picture background,
Callback (callback, event callback, the method to be executed after the button is clicked))
[] () {} represents the closure function, which is the c++11
function is to click the Picture button when changing the picture
Auto Menu = menu::create (Menuitemimage::create ("Ball_black.jpg", "ball_blue.jpg", [] (REF *) {
Log ("menu Item thouch!!!");
}), NULL);
Multiple menu buttons can be added
Auto menu1 = menu::create (Menuitemimage::create ("Ball_black.jpg", "ball_blue.jpg", [] (REF *) {
Log ("menu Item thouch!!!");
}), Menuitemimage::create ("Ball_blue.jpg", "ball_black.jpg", [] (REF *) {
Log ("menu Item thouch!!!");
}), NULL);
AddChild (menu1);//Add a menu into the layer
Cocos2d-x menu option Button Introduction