listener ->onKeyReleased = []( EventKeyboard ::KeyCode keyCode , Event * event ){
log ("KeyRelease:%d"槐哗 , keyCode )/余喊/TODO对各按键处理竖明野
}
_eventDispatcher ->addEventListenerWithSceneGraphPriority ( listener, this )
auto keyListener = EventListenerKeyboard::create()keyListener->setEnabled(true)
keyListener->onKeyReleased = CC_CALLBACK_2(HelloWorld::onKeyReleased, this)
keyListener->onKeyPressed = CC_CALLBACK_2(HelloWorld::onKeyPressed, this)
_eventDispatcher->addEventListenerWithSceneGraphPriority(keyListener, this)
void HelloWorld:: onKeyPressed(EventKeyboard::KeyCode keyCode, Event* unused_event) //闹册键盘被按下
{
cout<<"keyevent"
}
void HelloWorld::onKeyReleased(EventKeyboard::KeyCode keyCode, Event* unused_event) //键盘被释放
{
//cout<<&keyCode<早喊<"液睁宏keyevent two"
cout<<"keyevent two"
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)