2

我正在使用这样的 NSTimer

  GameTimer=[NSTimer scheduledTimerWithTimeInterval:60.0/60.0 target:self selector:@selector(Move) userInfo:nil repeats:YES];

在 Move 方法中,我更新了视图的位置。

-(void)Move
{

CGRect OldPosition=self.JumbleWordView.frame;
CGRect NewPosition=CGRectMake(OldPosition.origin.x, OldPosition.origin.y+MovementPerSec, OldPosition.size.width, OldPosition.size.height);

[self.JumbleWordView setFrame:NewPosition];
if (NewPosition.origin.y>=Slot_Left*CurrentBlockSize)
{
    [self checkResult];
    [Mytimer invalidate];
if (!isAnswerCorrect)
{
    [self swapViews];
    TotalRowPenalty=TotalRowPenalty+1;
    Score=Score+RowIncompletePoints;
    ScoreLab.text=[NSString stringWithFormat:@"%d",Score];
}
[self LoadNextWord];

}

如何暂停和恢复游戏计时器?

4

1 回答 1

1

NSTimer 没有暂停之类的东西,您必须停止并重新启动它。

[GameTimer invalidate]; //will stop the timer after which you can start it again
于 2013-04-15T06:03:01.173 回答