Last active
December 18, 2015 03:39
-
-
Save sdabet/5719684 to your computer and use it in GitHub Desktop.
Handle Android back button in cocos2d-iphone with Apportable (in MyNavigationController class)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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