Cocos2d-x3.0 捕捉Android的菜单键和返回键

前端之家收集整理的这篇文章主要介绍了Cocos2d-x3.0 捕捉Android的菜单键和返回键前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
1
void @H_404_14@ onKeyReleased(EventKeyboard::KeyCode keycode,Event* event);

.cpp 注册返回键监听

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// PrograssScene.cpp
// SJKB
//
// Created by 杜甲 on 14-5-5.
//
//
@H_404_14@#include PrograssScene.h
@H_404_14@#include VisibleRect.h
@H_404_14@bool PrograssScene::init()
@H_404_14@{
@H_404_14@bool bRet = false @H_404_14@;
do @H_404_14@ {
CC_BREAK_IF(!Scene::init());
//注册捕捉监听
auto listenerkeyPad = EventListenerKeyboard::create();
listenerkeyPad->onKeyReleased = CC_CALLBACK_2(PrograssScene::onKeyReleased, this @H_404_14@);
_eventDispatcher->addEventListenerWithSceneGraPHPriority(listenerkeyPad,monospace!important; font-size:1em!important; min-height:auto!important; background:none!important">);
_prograssLayer = PrograssLayer::create();
_prograssLayer->setSize(VisibleRect::getVisibleRect().size);
addChild(_prograssLayer);
bRet = true @H_404_14@;
} while @H_404_14@ ( 0 @H_404_14@);
return @H_404_14@ bRet;
@H_404_14@}
//捕捉监听
PrograssScene::onKeyReleased(EventKeyboard::KeyCode keycode,cocos2d::Event *event)
@H_404_14@{
if @H_404_14@ (keycode == EventKeyboard::KeyCode::KEY_BACKSPACE) //返回
{
Director::getInstance()->popScene();
}
else if @H_404_14@ (keycode == EventKeyboard::KeyCode::KEY_MENU)
{
}
@H_404_14@}
原文链接:https://www.f2er.com/cocos2dx/339807.html

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