Search code examples
androidcocos2d-x

android back key still not working in my game in cocos2d-x android c++


I have used

virtual void keyBackClicked();

in my helloworld.h and provided the definition in my .cpp

void HelloWorld:: keyBackClicked()
{
CCDirector::sharedDirector()->end();
}

My helloworld class in also inheriting cclayer class. I am using cocos2dx 2.2 But still its not working for android.Nothing is happening on pressing back key.How can I resolve this issue..tried many times.I have seen many posts and everywhere it is written the same logic. Can anyone please help.Thanks


Solution

  • You have to enable keyboard using setKeypadEnabled(true); method in your Layer init() or onEnter() method.