cocos2dx 物理按键

前端之家收集整理的这篇文章主要介绍了cocos2dx 物理按键前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
auto listener = EventListenerKeyboard::create();

    listener->onKeyReleased = [](EventKeyboard::KeyCode code,Event* event){
        switch (code)
        {
            case EventKeyboard::KeyCode::KEY_BACK:  //回退键
                Director::getInstance()->end(); break;
            case EventKeyboard::KeyCode::KEY_MENU:  //菜单Director::getInstance()->end(); break;
            default:
                break;
        }
    };

    Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraPHPriority(listener,this);
原文链接:https://www.f2er.com/cocos2dx/340083.html

猜你在找的Cocos2d-x相关文章