我正在使用像这样的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];
}
如何暂停和恢复游戏计时器?
答案 0 :(得分:1)
没有NSTimer暂停的事情,你必须停下来再启动它。
[GameTimer invalidate]; //will stop the timer after which you can start it again