我正在修正一个文字游戏,用户应该正确输入这个单词,但是如果他/她正确地输入了这个单词,那么第一次他们应该得到100分,每次他们在得分应该下降之后就错了10分......
到目前为止,我已经做到了这一点:
- (IBAction)btncheck:(id)sender {
NSString *answer = [_textbox.text stringByReplacingOccurrencesOfString:@" " withString:@""];
if([answer isEqualToString:@""]){
}
else
if ([answer isEqualToString:@"q"]) {
_keyboard.hidden = YES;
_textXclear.hidden = YES;
//Perfect button
[_closeone setHidden:NO];
[_wrongone setHidden:YES];
[_closetwo setHidden:NO];
score = 100;
[scoreLabel setText:[NSString stringWithFormat:@"score: %d", score]];
但它每次只分配100分,而不是为每个错误答案丢失分数! 有人会知道解决方案吗?
答案 0 :(得分:2)
score = 100;
。
score = score - 10;
当触及错误答案时。{/ p>
答案 1 :(得分:0)
一个不完整的例子:
Score = 110;
Guess = false;
While(Guess==false && Score > 0){
Guess=GetNextGuess(); // which sets guess to true if correct
Score -= 10;
}
// get here when score is zero or
// word was guessed correctly