Saturday 12 April 2014

Android back key enabled in cocos2d-x

How to enable the android back button key in cocos2d-x

Step 1. In your .h file which is inheriting CCLayer, write

virtual void keyBackClicked();

Step 2. Define this function in your .cpp file

void HelloWorld:: keyBackClicked()
{
//my code
}
Step 3. In your init() or onEnter method, write
this->setKeypadEnabled(true);
And you are done..

HAPPY CODING