.h
@interface ViewController : UIViewController
{
IBOutlet UILabel *countDownLabel;
NSTimer *gameTimeCount_Timer;
int gameCountDown_int;
int gameCountDown_minutes, gameCountDown_seconds;
}
@property (nonatomic, retain) UILabel *countDownLabel;
.m
#import "ViewController.h"
#define GAME_COUNTDOWN 71
@interface ViewController ()
@end
@implementation ViewController
@synthesize countDownLabel;
- (void)viewWillAppear:(BOOL)animated {
gameCountDown_int = GAME_COUNTDOWN;
gameTimeCount_Timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(GameTimer_Count) userInfo:nil repeats:YES];
}
- (void)GameTimer_Count {
if (gameCountDown_int > 0)
{
gameCountDown_int-- ;
gameCountDown_minutes = (gameCountDown_int % 3600) / 60;
gameCountDown_seconds = (gameCountDown_int % 3600) % 60;
countDownLabel.text = [NSString stringWithFormat:@"%02d:%02d", gameCountDown_minutes, gameCountDown_seconds];
}
}
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。