1

我试过这个 i OS Sprite Kit 教程并创建了一个类似的应用程序。但是,我注意到当我按下主页按钮转到 iOS 主屏幕时,我在 xCode 中遇到了错误的访问异常。当我回到应用程序时,它从头开始。

如何正确关闭/最小化 Sprite Kit 应用程序以避免该异常?

我在呈现场景的视图控制器中尝试了这个,但它没有被调用:

-(void)viewWillDisappear:(BOOL)animated
{
    SKView * skView = (SKView *)self.view;
    skView.paused = YES;
    [super viewWillDisappear:animated];
}
4

2 回答 2

0

我发现在 Sprite Kit 之上构建了 Kobold Kit sprite 引擎,在将我的项目移植到该引擎之后,我可以最小化应用程序并在屏幕上使用相同的内容恢复它!

于 2013-12-16T14:42:02.550 回答
-1

我相信处理最小化应用程序的正确方法是通过以下方法在 AppDelegate 中:

- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
于 2013-11-11T17:35:05.240 回答