我是这样写的:
auto ll = EventListenerKeyboard::create();
ll->onKeyPressed = CC_CALLBACK_2(Game::onKeyPressed, this);
this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(ll, this);
调用的函数
void Game::onKeyPressed(EventKeyboard::KeyCode keycode, Event*e){
if (keycode == EventKeyboard::KeyCode::KEY_BACKSPACE || keycode == EventKeyboard::KeyCode::KEY_BACK){
auto s = Start::createScene();
Director::getInstance()->replaceScene(s);
}
}
这样在win32下按BackSpace有用,在安卓平台下没反应
(还添加了个触摸事件监听)
求解决方案