bool HelloWorld::init()
{
if ( !Layer::init() )
{
return false;
}
auto listener=EventListenerKeyboard::create();
listener->onKeyReleased = [](EventKeyboard::KeyCode code,Event *e){
log("key code: %d",code);
switch (code) {
case EventKeyboard::KeyCode::KEY_BACKSPACE:
Director::getInstance()->end();
break;
default:
break;
}
};
return true;
}
时间: 2024-10-04 14:03:32