SpriteKit Pause and Resume SKView

笑着哭i 提交于 2019-12-01 10:41:41

You can't update the button (or anything else in the scene) while the SKView is paused. In your touchesBegan method, you are pausing the view before updating the button (changing the order won't work). You will need to return to the run loop so your button is updated before pausing the game. Here's one way to do that:

This calls a method to pause the view after a short delay. Add this after your [self Resume] statement in touchesBegan, and delete self.scene.view.paused = YES.

    [self performSelector:@selector(pauseGame) withObject:nil afterDelay:1/60.0];

This method pauses the SKView. Add this to your MyScene.m

- (void) pauseGame
{
    self.scene.view.paused = YES;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!