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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-19-2009, 04:20 PM   #51 (permalink)
Registered Member
 
Join Date: Oct 2008
Posts: 28
Default Restart crash

This would be awesome if someone could help!
dshaffer is offline   Reply With Quote
Old 11-27-2009, 12:26 AM   #52 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 1
Default

Quote:
Originally Posted by dshaffer View Post
This would be awesome if someone could help!
So i am assuming that no-one got the restart to work?

I do have another question, how would i go about creating a quiz that had images as a part of the question? I want to make something for revision for my students so they look at the image, the question displays below it and there are 4 options to choose from.

If anyone could help me out i would appreciate it, and yes i know the thread is quite old.

Cheers,
boombah is offline   Reply With Quote
Old 11-27-2009, 04:23 PM   #53 (permalink)
Registered Member
 
Join Date: Sep 2008
Posts: 54
Default

Quote:
Originally Posted by boombah View Post
So i am assuming that no-one got the restart to work?

I do have another question, how would i go about creating a quiz that had images as a part of the question? I want to make something for revision for my students so they look at the image, the question displays below it and there are 4 options to choose from.

If anyone could help me out i would appreciate it, and yes i know the thread is quite old.

Cheers,
All you have to do is call

[Self loadView];

To load the game to start over
duny is offline   Reply With Quote
Old 02-12-2010, 10:24 AM   #54 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 24
Default

Quote:
Originally Posted by sarahconnor View Post
So THIS TIME IT IS attached is the file for the Quiz using IB, but i changed up the quiz a lil bit. The only thing it is missing is when you hit the restart button, it will not load again! If any one can figure this out, PLEASE let me know!!!!!

Thanks!

Mandy
Hello All,

Just wondering if anyones knows how use a txt file for the questions instead of an array?
learningCentres is offline   Reply With Quote
Old 02-22-2010, 06:46 AM   #55 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 32
Default

What exactly do I need to insert to pick a question randomly?

And If i want to include an image to a specefic question, how do I do that?

+ How do I define how many questions you'll get? For example, each quiz will have 10 questions randomly chosen out of 200 questions...

Thanks!

Last edited by jumbo0; 02-22-2010 at 09:33 AM.
jumbo0 is offline   Reply With Quote
Old 02-22-2010, 11:17 AM   #56 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 24
Default

An answer to the above would really help me too...
learningCentres is offline   Reply With Quote
Old 03-05-2010, 06:44 AM   #57 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 75
Question

Code:
- (void)viewDidLoad {
    [super viewDidLoad];
	questionLive = NO;
	restartGame = NO;
	theQuestion.text = @"Welcome to the Quiz Game! Think you're a pretty smart cookie, huh? Well, let's test your knowledge!";
	theScore.text = @"Score:0";
	theLives.text = @"";
	questionNumber = 0;
	myScore = 0;
	myLives = 0;
	[answerOne setTitle:@"Let's Play!" forState:UIControlStateNormal];
	[answerTwo setHidden:YES];
	[answerThree setHidden:YES];
	[answerFour setHidden:YES];
	[self loadQuiz];
}

In the code above, [answerOne setTitle:@"Let's Play!" forState:UIControlStateNormal];

It requires user to click answerOne button and starts the quiz.

How can the quiz display without click that button? When the app starts, first quiz display.

I tried to change it to be:
[answerOne setHidden:YES];

But, it does not work.

How should I fix it?

Secondly, how can it load the quizgame.txt which has non-English words? Does it need any encoding?

Last edited by webphone; 03-05-2010 at 06:46 AM. Reason: miss one question
webphone is offline   Reply With Quote
Old 03-08-2010, 07:14 AM   #58 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 7
Default SQLite

I'm trying to convert this tutorial into a maths "Times Tables" quiz.

I was wondering if anyone could lend a hand and explaining how to remove the multiple choice element and replace it with a text box and number pad, generate a times tables question and be able to compare the answer typed with the correct answer.

I was thinking either having
•*list all the times table and answers in a DB?
or
• having the app create the times tables questions and answers as the app is running and store the results in a DB?

Please help this is my University project and I've only got till april 30th.
siptash is offline   Reply With Quote
Old 03-08-2010, 07:16 AM   #59 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 7
Default Times Tables App

Sorry entered twice...
siptash is offline   Reply With Quote
Old 03-13-2010, 08:44 PM   #60 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 43
Default

I have tried many different things now, and nothing really works for me

First i want to pick a random question out of a lot (100+)
I have tried with some arc4random(), but not really works
Code:
	questionNumber = questionNumber + 1;
I dont know how hard it would be to make it remember that question that have been asked (guess that is pretty hard)

Second i want to be able to restart the game, and this [self loadView] doesn't really help.

when i try this:
Code:
- (IBAction)buttonOne
{
	if(questionNumber == 0){
		// This means that we are at the startup-state
		// We need to make the other buttons visible, and start the game.
		[answerTwo setHidden:NO];
		[answerThree setHidden:NO];
		[answerFour setHidden:NO];
		[self askQuestion];
	}
	else
	{
		NSInteger theAnswerValue = 1;
		[self checkAnswer:(int)theAnswerValue];
		if(restartGame==YES)
		{

			NSLog(@"meh");
			//RESTART Function here
			
		}
	}
}
I get the log "meh" as a answer the last question and not when i press the restart button, very odd.

Hope someone can help, since this is a great tutorial, but needs the last method (restart please).

-Drudoo
__________________
My iPhone apps!
ezyTweet - $0.99
iZky - $0.99
Drudoo is offline   Reply With Quote
Old 04-22-2010, 10:04 AM   #61 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 7
Default [Self loadView];

Quote:
Originally Posted by duny View Post
All you have to do is call

[Self loadView];

To load the game to start over
I've tried [Self loadView]; and it still continues to crash!

What am i doing wrong, sorry for been such a noob!
siptash is offline   Reply With Quote
Old 07-26-2010, 09:14 AM   #62 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 43
Default

Im trying to make it choose a random number out of a lot of questions. The arc4random() method wont work cus i needs to be number 1 or 7 or 14 or 21 or 28 and so on. Is there a way to make it only choose between those numbers?
__________________
My iPhone apps!
ezyTweet - $0.99
iZky - $0.99
Drudoo is offline   Reply With Quote
Old 08-07-2010, 08:22 PM   #63 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 2
Default

Quote:
Originally Posted by Drudoo View Post
Im trying to make it choose a random number out of a lot of questions. The arc4random() method wont work cus i needs to be number 1 or 7 or 14 or 21 or 28 and so on. Is there a way to make it only choose between those numbers?
Hi, yes I did it with the arc4random() , just use it and % to the number of questions you have , and then multiply that number for the numbers of row to "jump" , 6 in this case, because you have 1 question at each 6 rows

it worked great for me

I have my quiz app almost ready!
sifondev is offline   Reply With Quote
Old 08-17-2010, 02:54 PM   #64 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 2
Default

Does someone have this working when it's loading from a text file? The code in the first post was deprecated. I've since fixed it to be 4.0 compatible, but I'm getting an NSRangeException when I load in the text file.
jnce is offline   Reply With Quote
Old 08-19-2010, 06:15 PM   #65 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 195
Default

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];	
	
	
}
phillipie99 is offline   Reply With Quote
Old 08-31-2010, 11:41 AM   #66 (permalink)
Registered Member
 
Join Date: Aug 2010
Location: Ipswich UK
Posts: 6
Default

Hey, bit of a bump but oh well.

Did anyone get the arc4random working? If they did can they post up their code as it is confusing me way too much.

Currently have got the quiz working well but need this random feature to draw in 10 questions from a list of 50 or more.
peewee1002 is offline   Reply With Quote
Old 09-01-2010, 07:41 AM   #67 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Enschede, Netherlands
Posts: 198
Default

Like I said in your topic, see this:
http://www.iphonedevsdk.com/forum/ip...-question.html
rickrets is offline   Reply With Quote
Old 09-03-2010, 11:54 AM   #68 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 2
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
Old 09-04-2010, 04:04 PM   #69 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 195
Default

Quote:
Originally Posted by gatorcade View Post
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];


}
You screwed up this part

Code:
		
		// 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];
__________________
My new app Catch The Coconut.
Website: PhilBystricanApps.com
phillipie99 is offline   Reply With Quote
Old 09-28-2010, 11:24 AM   #70 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 2
Default quiz

Quote:
Originally Posted by phillipie99 View Post
You screwed up this part

Code:
		
		// 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];
It works.

Thank You So Much.
gatorcade is offline   Reply With Quote
Old 09-28-2010, 08:23 PM   #71 (permalink)
Registered Member
 
Join Date: Sep 2010
Location: Eastampton, NJ USA
Posts: 34
Default

Quote:
Originally Posted by rickrets View Post
Like I said in your topic, see this:
http://www.iphonedevsdk.com/forum/ip...-question.html
I'm having trouble with this. I followed the link, but am not understanding it. Does anyone have any better documentation (doesn't have to be the exact code) but just notes on how to implement the random questions from the array?
Fedcis09 is offline   Reply With Quote
Old 11-02-2010, 11:56 AM   #72 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 26
Default

in -(void)loadQuiz - xxxViewController.m

Before:
PHP Code:
NSString *fileContents = [NSString stringWithContentsOfFile:textFilePath]; 
after:
PHP Code:
    NSString *fileContents = [NSString stringWithContentsOfFile:textFilePath encoding:NSUTF8StringEncoding error:nil];
    [
NSString stringWithContentsOfFile:textFilePath encoding:NSUTF8StringEncoding error:nil]; 
To make it import ex åöä etc.
tobban2 is offline   Reply With Quote
Old 11-02-2010, 07:30 PM   #73 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 7
Default it crashes when I restart the quiz qpplying this code?

Quote:
Originally Posted by gatorcade View Post
It works.

Thank You So Much.
Can you post your working code here please?
alexleroi is offline   Reply With Quote
Old 11-03-2010, 07:56 AM   #74 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 7
Default

Quote:
Originally Posted by phillipie99 View Post
You screwed up this part

Code:
		
		// 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];


My problem is the endgame par I mean when the quiz answer the last question the program freezes?!!!! Any idea why?
alexleroi is offline   Reply With Quote
Old 11-03-2010, 09:44 AM   #75 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 26
Default

Quote:
Originally Posted by alexleroi View Post
My problem is the endgame par I mean when the quiz answer the last question the program freezes?!!!! Any idea why?
How many questions do you have? With under 3 questions it freezes for me. With 3 or over it works. But cant get reset to work.
tobban2 is offline   Reply With Quote
Reply

Bookmarks

Tags
game, quiz, tutorial

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 253
19 members and 234 guests
2WeeksToGo, @sandris, AdamL, ADY, BrianSlick, Dani77, diyora, F_Bryant, GHuebner, HDshot, headkaze, mer10, prchn4christ, Rudy, smithdale87, Thompson22, timle8n1, Touchmint, vigu360
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,748
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:54 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0