0

我在查找有关暂停/恢复应用程序的信息时遇到了一些麻烦。我能找到的唯一信息是暂停/恢复音频文件。我已经构建了一个类似于“西蒙”游戏的应用程序(您必须重复一系列按钮),但我在实现暂停功能时遇到了麻烦。我想在屏幕顶部有一个显示“暂停”的按钮,点击它会暂停游戏并将按钮的文本更改为基本上说“恢复”,我希望除“恢复”按钮之外的所有内容都冻结。

我已经设置了我认为可以确定按钮状态的设置,但我不知道在里面放什么;到目前为止,我处理过的唯一一种等待功能是睡眠预定时间长度的功能(NSTimer 等)

如果有人可以提供帮助,我将不胜感激!

- (IBAction)paused:(id)sender
{
  UIButton *pause = (UIbutton *)sender;
  NSString *state = pause.titleLabel.text; 
  if ([state isEqualToString:@"Pause"])
  {
   //If the text is set to 'pause' that means the game is running 
   //pressing this button will pause the game
  }else
  {
   //If the text is set to resume that means the game is paused
   //pressing this button will resume the game
  }
}
4

0 回答 0