Android back key enabled in cocos2d-x | Techbirds
Posted on: September 19, 2015 /
Categories: Android Apps, Mobile Applications
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 On Tags: android, cocos2dx