Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何按正确的顺序设置分数(100分为第一名)-(90分为第二名)-(80分为第三名)?_Ios_Iphone_Objective C - Fatal编程技术网

Ios 如何按正确的顺序设置分数(100分为第一名)-(90分为第二名)-(80分为第三名)?

Ios 如何按正确的顺序设置分数(100分为第一名)-(90分为第二名)-(80分为第三名)?,ios,iphone,objective-c,Ios,Iphone,Objective C,我正在修复一个文字游戏,用户应该正确键入文字,但是如果他/她第一次键入正确,他们应该得到100分,每次他们在那里出错后,分数应该下降10分 到目前为止,我已经做到了: - (IBAction)btncheck:(id)sender { NSString *answer = [_textbox.text stringByReplacingOccurrencesOfString:@" " withString:@""]; if([answer isEqualToString:@""]){ } els

我正在修复一个文字游戏,用户应该正确键入文字,但是如果他/她第一次键入正确,他们应该得到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分,而不是每答错一次就丢分!! 有人知道解决方案吗?

一个不完整的例子:

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

score=100在初始化方法中。

score=得分-10当触摸到错误答案时。

if语句的
第一部分是空的吗????如果你什么都不做,这真的需要吗???在循环之前将score设置为100,在循环内部减少10…@floris我该怎么做?看看你的代码,你正在将score设置为100,然后将label.text设置为score,每次都是100。您的代码在哪里尝试执行“score-=10;”?@OthmanTazi这是真的,我将如何修复它?让我尝试一下如果([回答isEqualToString:@“q”]){score=score+100;[scoreLabel setText:[NSString stringWithFormat:@“score:%d”,score]];}其他{score=score-10;[scoreLabel setText:[NSString stringWithFormat:@“score:%d”,score]];}