Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 09-03-2010, 10:54 AM   #68 (permalink)
gatorcade
Registered Member
 
Join Date: May 2010
Posts: 2
gatorcade is on a distinguished road
Default

Quote:
Originally Posted by phillipie99 View Post
Got the reset working
All you have to do is copy the new update score method just the last few line before the else are changed. Then add the
Code:
-(void)reset;
to the Quiz game view controller.h file and finally add the reset method below to the Quiz game view controller.m file. There you go a working reset!!
Code:
-(void)updateScore
{
	// If the score is being updated, the question is not live
	questionLive = NO;
	
	[timer invalidate];
	
	// Hide the answers from the previous question
	[answerOne setHidden:YES];
	[answerTwo setHidden:YES];
	[answerThree setHidden:YES];
	[answerFour setHidden:YES];
	NSString *scoreUpdate = [[NSString alloc] initWithFormat:@"Score: %d", myScore];
	theScore.text = scoreUpdate;
	[scoreUpdate release];
	
	// END THE GAME.
	NSInteger endOfQuiz = [theQuiz count];
	if((((questionNumber - 1) * 6) + 6) == endOfQuiz)
	{
		// Game is over.
		if(myScore > 0)
		{
			NSString *finishingStatement = [[NSString alloc] initWithFormat:@"That's game!\nNice going \nYou scored %i!", myScore];
			theQuestion.text = finishingStatement;
			[finishingStatement release];
		}
		else
		{
			NSString *finishingStatement = [[NSString alloc] initWithFormat:@"That's game!\nWow. You're terrible! \nYou scored %i.", myScore];
			theQuestion.text = finishingStatement;
			[finishingStatement release];
		}
		theLives.text = @"";
		
		// Make button 1 appear as a reset game button
		restartGame = YES;
		[answerOne setHidden:NO];
		[answerOne addTarget:self action:@selector(reset)forControlEvents:UIControlEventTouchDown];
		[answerOne setTitle:@"Restart the game" forState:UIControlStateNormal];
		

		
		
		
	}
	else
	{
	// Give a short rest between questions
	time = 3.0;
	
	// Initialize the timer
	timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(countDown) userInfo:nil repeats:YES];
	}
}

// RESET METHOD
-(void)reset {
	
	[self viewDidLoad];	
	
	
}
Did not work for me. Could you please help?

(Quiz game view controller.h):

-(void)checkAnswerint)theAnswerValue;
-(void)askQuestion;
-(void)updateScore;
-(void)loadLevelOne;
-(void)countDown;
-(void)reset;

@end

Quiz game view controller.m file:


-(void)updateScore
{

questionLive = NO;

[timer invalidate];


[answerOne setHidden:YES];
[answerTwo setHidden:YES];
[answerThree setHidden:YES];
[answerFour setHidden:YES];
NSString *scoreUpdate = [[NSString alloc] initWithFormat:@"%i", myScore];
theScore.text = scoreUpdate;
[scoreUpdate release];

// END THE GAME.
NSInteger endOfQuiz = [theQuiz count];
if((((questionNumber - 1) * 6) + 6) == endOfQuiz)
{

if(myScore > 0)
{
NSString *finishingStatement = [[NSString alloc] initWithFormat:@"You scored %i!", myScore];
theQuestion.textColor = [UIColor colorWithRed:0 green:0.2 blue:0 alpha:1.0];
theQuestion.text = finishingStatement;
[finishingStatement release];
}
else
{
NSString *finishingStatement = [[NSString alloc] initWithFormat:@"You scored %i.", myScore];
theQuestion.textColor = [UIColor redColor];
theQuestion.text = finishingStatement;
[finishingStatement release];
}
theLives.text = @"";


restartGame = YES;
[answerTwo setHidden:NO];
[answerTwo setTitle:@"Restart" forState:UIControlStateNormal];

}
else
{

time = 3.0;


timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(countDown) userInfo:nil repeats:YES];
}
}

// RESET METHOD
-(void)reset {

[self viewDidLoad];


}
gatorcade is offline   Reply With Quote
 

» Advertisements
» Online Users: 386
9 members and 377 guests
Absentia, breennorah, dennisnederlof, Domele, ipodphone, Matl43Owa, mjnafjke, Paul Slocum, raymng
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,579
Threads: 94,082
Posts: 402,769
Top Poster: BrianSlick (7,990)
Welcome to our newest member, breennorah
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:45 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.