Android back key enabled in cocos2d-x | Techbirds

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

819 total views, 1 views today

Share this Onfacebook-4558695twitter-2371055linkedin-3006098google-7995693 Tags: android, cocos2dx