【问题标题】:Back button in Cocos2d-x 3.2 AndroidCocos2d-x 3.2 Android 中的返回按钮
【发布时间】:2014-12-11 09:38:57
【问题描述】:

我想使用 Cocos2d-x 3.2 检测 Android 上的后退按钮按下事件。 我研究了一些主题,但这些方法适用于 Cocos2d-x 2.x,在 3.2 版本中已弃用。 我试过了

listener_ = EventListenerKeyboard::create();
listener_->onKeyPressed = CC_CALLBACK_2(GameOverScene::onKeyPressed, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener_, this);

但没有检测到任何东西。

请你帮帮我吧!

非常感谢!

【问题讨论】:

    标签: android cocos2d-x cocos2d-x-3.0


    【解决方案1】:

    我的问题解决了

    auto listener = EventListenerKeyboard::create();
    listener->onKeyReleased = [](EventKeyboard::KeyCode keyCode, Event* event){
        Director::getInstance()->end();
    };
    
    _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
    

    非常感谢!

    【讨论】:

      猜你喜欢
      • 2014-07-25
      • 1970-01-01
      • 1970-01-01
      • 2016-12-30
      • 1970-01-01
      • 2014-10-08
      • 1970-01-01
      • 2014-09-27
      • 2023-03-28
      相关资源
      最近更新 更多