我是App Development的新手,对不起,如果我问愚蠢的问题:( 我正在开发一个测验应用程序。每当我给出正确或错误的答案时,图像会出现正确或错误的答案结果,但是它会停留几秒钟,但在此之后 - 它不会继续下一个问题。它只是用按钮显示我的背景图像。当结果图像消失时,如何设置代码,直接转到新问题。 我将非常感谢你的帮助。
我只想在结果图像关闭后,测验继续下一个问题。
这是我在Game.m文件中设置的代码。
-(void)RightAnswer{
ScoreNumber = ScoreNumber + 1;
Score.text = [NSString stringWithFormat:@"%i", ScoreNumber];
Answer1.hidden = YES;
Answer2.hidden = YES;
Answer3.hidden = YES;
CategorySelected.hidden = NO;
Next.hidden = NO;
imageQuestion.hidden = YES;
Results.hidden = NO;
Results.image = [UIImage imageNamed:@"right.png"]; [self performSelector:@selector(Results) withObject:nil afterDelay:2.0];
GameInProgress = YES;
}
-(void)WrongAnswer{
LivesNumber = LivesNumber - 1;
Lives.text = [NSString stringWithFormat:@"%i", LivesNumber];
Answer1.hidden = YES;
Answer2.hidden = YES;
Answer3.hidden = YES;
imageQuestion.hidden = YES;
CategorySelected.hidden = NO;
Next.hidden = NO;
Results.hidden = NO;
Results.image = [UIImage imageNamed:@"wrong.png"];[self performSelector:@selector(Results) withObject:nil afterDelay:2.0];
GameInProgress = YES;
if(LivesNumber ==0) {
Results.image = [UIImage imageNamed:@"gameover.png"];
GameInProgress = NO;
Exit.hidden = NO;
}
答案 0 :(得分:0)
我可能在这里错了,但我认为你需要一个if to the else。 但我可能是错的。
if(LivesNumber ==0) {
Results.image = [UIImage imageNamed:@"gameover.png"];
GameInProgress = NO;
Exit.hidden = NO;
}else{
donextcard();
}
如果您想知道如何制作该功能,我们需要查看更多代码。
答案 1 :(得分:0)
-(void)Results{ // just change formate of answer.
Results.hidden = YES;
}
-(IBAction)Answer1: (id) sender{
if (Answer1Correct ==YES) {
[self RightAnswer];
}else{
[self WrongAnswer];
}
}
-(IBAction)Answer2: (id) sender{
if (Answer2Correct ==YES) {
[self RightAnswer];
}
else{
[self WrongAnswer];
}
}
-(IBAction)Answer3: (id) sender{
if (Answer3Correct ==YES) {
[self RightAnswer];
}
else{
[self WrongAnswer];
}
}
答案 2 :(得分:0)
-(void)RightAnswer{
ScoreNumber = ScoreNumber + 1;
Score.text = [NSString stringWithFormat:@"%i", ScoreNumber];
Answer1.hidden = YES;
Answer2.hidden = YES;
Answer3.hidden = YES;
Answer1Correct ==YES;
CategorySelected.hidden = NO;
Next.hidden = NO;
imageQuestion.hidden = YES;
Results.hidden = NO;
Results.image = [UIImage imageNamed:@"right.png"]; [self performSelector:@selector(Results) withObject:nil afterDelay:2.0];
GameInProgress = YES;
}
我认为问题是你永远不会将Answer1Correct设置为任何东西。所以如果你将Answer1Correct == YES添加到正确的答案方法并且Answer1Correct == NO添加到错误的方法那么它应该工作