2015년 12월 30일 수요일

Cocos2d-x android back button


Cocos2d-x 3.x version,

if use android back button,
in scene class add this code.
(I add this code on 'init' function)
this->setKeypadEnabled(true);

And add event listener

void className::onKeyReleased(cocos2d::EventKeyboard::KeyCode keycode, cocos2d::Event* e)
{
if(EventKeyboard::KeyCode::KEY_MENU == keycode)
{
//do something
}
if(EventKeyboard::KeyCode::KEY_BACK == keycode)
{
//do something
}

}

if you want example code

//this->setKeypadEnabled(true);
https://github.com/pineoc/robot-puzzle/blob/master/Classes/p1Scene.cpp#L115,

//event listener
https://github.com/pineoc/robot-puzzle/blob/master/Classes/p1Scene.cpp#L205

This project make puzzle game
:)

good luck make games

댓글 없음:

댓글 쓰기

JIRA Plugin - ScriptRunner 소개 #2

관련 글 소개 #1:  https://pineoc.blogspot.com/2019/03/scriptrunner-1.html ScriptRunner 소개 #2 지난 글에서는 Behaviours를 보았고 다음 내용인 콘솔, 리스너 등을 ...