Skip to content

Instantly share code, notes, and snippets.

@sdabet

sdabet/AppDelegate.m

Last active Dec 18, 2015
Embed
What would you like to do?
Handle Android back button in cocos2d-iphone with Apportable (in MyNavigationController class)
#ifdef APPORTABLE
- (BOOL) canBecomeFirstResponder
{
return YES;
}
- (void)buttonUpWithEvent:(UIEvent *)event
{
switch (event.buttonCode)
{
case UIEventButtonCodeBack:
// Back button is pressed
// Pop current scene
[[CCDirector sharedDirector] popScene];
// Terminate the app if scene stack is empty
if([[CCDirector sharedDirector] runningScene] == nil) {
exit(0);
}
break;
case UIEventButtonCodeMenu:
// show menu if possible.
break;
default:
break;
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment