I'm trying to pause my game when the app gets interrupted! (like Phonecalls, SMS, etc.)
I created a pause menu in my Game Viewcontroller (rush_gamemode).
When I press the pause Button in the game everything works just fine. If I call the method via "applicationWillResignActive" in AppDelegate it does work kind of.
Here's my Code:
in rush_gamemode.h
-(void)goIntoPause;
in rush_gamemode.m
-(void)goIntoPause
{
NSLog(@"RUSH goIntoPause was called!");
self.Button_Pause.hidden = YES;
//--------pause timer-------//
if (self.timerStart) {
timerWasStarted = YES;
self.oldTimeNumber = self.timeNumber;
[self.timerStart invalidate];
self.timerStart = nil;
}
//--------set up pause menu--------//
self.transparent_subview_background.alpha = 0;
self.Pause_Subview.hidden = NO;
self.Pause_Subview.backgroundColor = [UIColor clearColor];
[UIView beginAnimations:NULL context:NULL];
[UIView setAnimationDuration:.75];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[self.transparent_subview_background setAlpha:0.75];
[UIView commitAnimations];
}
in AppDelegate.h
@class rush_gamemode;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
rush_gamemode* rush;
}
in AppDelegate.m I imported "rush_gamemode.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
rush = [[rush_gamemode alloc] init];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
[rush goIntoPause];
}
So when I start the App, and press the HomeButton (e.g) or get a Phone call, the console shows the NSLog ("RUSH goIntoPause was called!") but doesn't do anything else..
What am I doing wrong here?
cheers, Niklas