Hi all!
I’m trying to create cocos2d-x game for Tizen.
How to handle hardware Back button pressing?
It’s important for me at this time.
Hi,
just have a look at this commit and it should be straight forward. I managed to submit a game for the tizen platform with this branch , which is based on pyrasis work .
Happy coding!
Hi Michael,
Thank you for your reply.
I want to handle back button in CCLayer.
Is it possible?
Sure, listen for keyboard events in your CCLayer
and do whatever you want if it’s cocos2d::EventKeyboard::KeyCode::KEY_BACKSPACE
It’s the same handling / behaviour as the hardware back button on Android!
How are you compiling this branch “tizen_2.2_fix” on tizen, I am getting "error: expected ‘,’ before final on all deprecated function declaration.
I am thinking it’s because of c11 standard issue. When i am trying to build it on c11, tizen compiler says unrecognised flag.
Hi, I just pushed a few missing commits and it should work now
Hi meme,
I’m not 100% sure but for cocos2dx 2.2 you need to trigger dispatchKeypadMSG(kTypeBackClicked)
of the CCKeypadDispatcher
.
So just replace the two lines with the EventKeyboard
of this patch with something like CCKeypadDispatcher::sharedDispatcher()->dispatchKeypadMSG(kTypeBackClicked)
. After that you just need to enable the keypad with setKeypadEnabled(true)
and put your code in void CCLayer::keyBackClicked()
.
Again — I’m not sure and haven’t tested it! But maybe this is a good starting point for you!?
- https://github.com/cocos2d/cocos2d-x/blob/master/cocos2dx/CCDirector.h#L347
- https://github.com/cocos2d/cocos2d-x/blob/master/cocos2dx/keypad_dispatcher/CCKeypadDispatcher.h#L80
And please don’t get this wrong: Do you have even some coding / c++ experience? If not, please grab a book and start reading. I’m very happy to help someone in this board but, as a general rules for all boards, we’re not here to write your code / solve your homework And figuring out how to handle key events in cocos2dx or to find the right class if some names has been changed … that should be manageable for everyone who works with cocos2dx