Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.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 游戏在Xcode 6中搞砸了?_Ios_Objective C_Xcode6 - Fatal编程技术网

Ios 游戏在Xcode 6中搞砸了?

Ios 游戏在Xcode 6中搞砸了?,ios,objective-c,xcode6,Ios,Objective C,Xcode6,在Xcode 5中,我的游戏运行得很好,当我的电脑升级到Xcode 6时,它出现了bug。我不知道到底发生了什么事。我认为这可能与显示分数的文本所连接的字符串有关。每当比分变为1时,游戏重新开始。可能是触摸中的某些编码错误开始:withEvent: 游戏是一艘潜水艇,它穿过一个洞穴,每半秒就可以获得积分,当潜水艇击中硬币时可以获得硬币。下面是可能的代码部分,但我甚至不知道错误来自何处 -(void)NewGame{ Coin.hidden = YES; Coin2.hidden

在Xcode 5中,我的游戏运行得很好,当我的电脑升级到Xcode 6时,它出现了bug。我不知道到底发生了什么事。我认为这可能与显示分数的文本所连接的字符串有关。每当比分变为1时,游戏重新开始。可能是触摸中的某些编码错误开始:withEvent:

游戏是一艘潜水艇,它穿过一个洞穴,每半秒就可以获得积分,当潜水艇击中硬币时可以获得硬币。下面是可能的代码部分,但我甚至不知道错误来自何处

-(void)NewGame{
    Coin.hidden = YES;
    Coin2.hidden = YES;

    Ruby.hidden = YES;
    Ruby2.hidden = YES;

    Intro1.hidden = NO;
    Intro2.hidden = NO;
    Intro3.hidden = NO;
    Intro8.hidden = NO;
    IntroC.hidden = NO;

    Start = YES;
    ScoreNumber = 0;
    Score.text = [NSString stringWithFormat:@"Score: 0"];
    CoinNumber = 0;
    CoinCount.text = [NSString stringWithFormat:@"Coins: 0"];


    Intro3.text = [NSString stringWithFormat:@"HighScore: %i", HighScoreAttack];

    IntroC.text = [NSString stringWithFormat:@"Total Coins: %i", TotalCoins];
}

-(void)Fishmove {
    [self Collision];

    Submarine.center = CGPointMake(Submaine.center.x, Submarine.center.y + y);


    Obstacle.center = CGPointMake(Obstacle.center.x - 10, Obstacle.center.y);
    Obstacle2.center = CGPointMake(Obstacle2.center.x - 10, Obstacle2.center.y);
    Bottom1.center = CGPointMake(Bottom1.center.x - 10, Bottom1.center.y);
    Bottom2.center = CGPointMake(Bottom2.center.x - 10, Bottom2.center.y);
    Bottom3.center = CGPointMake(Bottom3.center.x - 10, Bottom3.center.y);
    Bottom4.center = CGPointMake(Bottom4.center.x - 10, Bottom4.center.y);
    Bottom5.center = CGPointMake(Bottom5.center.x - 10, Bottom5.center.y);
    Bottom6.center = CGPointMake(Bottom6.center.x - 10, Bottom6.center.y);
    Bottom7.center = CGPointMake(Bottom7.center.x - 10, Bottom7.center.y);
    Top1.center = CGPointMake(Top1.center.x - 10, Top1.center.y);
    Top2.center = CGPointMake(Top2.center.x - 10, Top2.center.y);
    Top3.center = CGPointMake(Top3.center.x - 10, Top3.center.y);
    Top4.center = CGPointMake(Top4.center.x - 10, Top4.center.y);
    Top5.center = CGPointMake(Top5.center.x - 10, Top5.center.y);
    Top6.center = CGPointMake(Top6.center.x - 10, Top6.center.y);
    Top7.center = CGPointMake(Top7.center.x - 10, Top7.center.y);
    Coin.center = CGPointMake(Coin.center.x - 10, Coin.center.y);
    Coin2.center = CGPointMake(Coin2.center.x - 10, Coin2.center.y);
    Ruby.center = CGPointMake(Ruby.center.x - 10, Ruby.center.y);
    Ruby2.center = CGPointMake(Ruby2.center.x - 10, Ruby2.center.y);


    if (Obstacle.center.x < 0) {
        Obstacle.hidden = NO;
        RadnomPosition = arc4random() %75;
        RadnomPosition = RadnomPosition +110;
        Obstacle.center = CGPointMake(560, RadnomPosition);
    }

    if (Obstacle2.center.x < 0) {
        Obstacle2.hidden = NO;
        RadnomPosition = arc4random() %75;
        RadnomPosition = RadnomPosition + 110;
        Obstacle2.center = CGPointMake(560, RadnomPosition);

    }


    if (Coin.center.x < 0) {
        Coin.hidden = NO;
        RadnomPosition = arc4random() %250;
        RadnomPosition = RadnomPosition +110;
        Coin.center = CGPointMake(560, RadnomPosition);
    }

    if (Coin2.center.x < 0) {
        Coin2.hidden = NO;
        RadnomPosition = arc4random() %150;
        RadnomPosition = RadnomPosition + 110;
        Coin2.center = CGPointMake(560, RadnomPosition);
    }
    if (Coin.center.y > 250) {
        Coin.hidden = YES;
    }
    if (Coin2.center.y > 250) {
        Coin2.hidden = YES;
    }
}


-(void)Scoring{
    ScoreNumber = ScoreNumber + 1;
    Score.text = [NSString stringWithFormat:@"Score: %i",ScoreNumber];
}

(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    if (Start == YES) {

        Intro1.hidden = YES;


        timer = [NSTimer scheduledTimerWithTimeInterval:0.05 target: self selector:@selector(Fishmove) userInfo:nil repeats:YES];

        Scorer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(Scoring) userInfo:nil repeats:YES];


        CoinScorer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(Collision) userInfo:nil repeats:YES];
        Start = NO;

        Obstacle2.hidden = NO;

        Coin.hidden = NO;
        Coin2.hidden = NO;

        RadnomPosition = arc4random() %75;
        RadnomPosition = RadnomPosition + 110;
        Obstacle.center = CGPointMake(570, RadnomPosition);

        RadnomPosition = arc4random() %75;
        RadnomPosition = RadnomPosition + 110;
        Obstacle2.center = CGPointMake(855, RadnomPosition);


        RadnomPosition = arc4random() %75;
        RadnomPosition = RadnomPosition + 110;
        Coin.center = CGPointMake(712.5, RadnomPosition);

        RadnomPosition = arc4random() %75;
        RadnomPosition = RadnomPosition + 110;
        Coin2.center = CGPointMake(997.5, RadnomPosition);


        RadnomPosition = arc4random() %75;
        RadnomPosition = RadnomPosition + 110;
        Ruby.center = CGPointMake(712.5, RadnomPosition);

        RadnomPosition = arc4random() %75;
        RadnomPosition = RadnomPosition + 110;
        Ruby2.center = CGPointMake(997.5, RadnomPosition);

        RadnomPosition = arc4random() %55;
        Top1.center = CGPointMake(560, RadnomPosition);
        RadnomPosition = RadnomPosition + 265;
        Bottom1.center = CGPointMake(560, RadnomPosition);

        RadnomPosition = arc4random() %55;
        Top2.center = CGPointMake(640, RadnomPosition);
        RadnomPosition = RadnomPosition + 265;
        Bottom2.center = CGPointMake(640, RadnomPosition);

        RadnomPosition = arc4random() %55;
        Top3.center = CGPointMake(720, RadnomPosition);
        RadnomPosition = RadnomPosition + 265;
        Bottom3.center = CGPointMake(720, RadnomPosition);

        RadnomPosition = arc4random() %55;
        Top4.center = CGPointMake(800, RadnomPosition);
        RadnomPosition = RadnomPosition + 265;
        Bottom4.center = CGPointMake(800, RadnomPosition);

        RadnomPosition = arc4random() %55;
        Top5.center = CGPointMake(880, RadnomPosition);
        RadnomPosition = RadnomPosition + 265;
        Bottom5.center = CGPointMake(880, RadnomPosition);

        RadnomPosition = arc4random() %55;
        Top6.center = CGPointMake(960, RadnomPosition);
        RadnomPosition = RadnomPosition + 265;
        Bottom6.center = CGPointMake(960, RadnomPosition);

        RadnomPosition = arc4random() %55;
        Top7.center = CGPointMake(1140, RadnomPosition);
        RadnomPosition = RadnomPosition + 265;
        Bottom7.center = CGPointMake(1140, RadnomPosition);
    }
    y = -7;
}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
    y = 7;
}

问题在于调用在不应该重置游戏时重置游戏的方法。你遗漏了碰撞方法,所以我不知道该方法的作用。我看不出在发布的代码中有什么东西会重置游戏

我认为问题可能在于你的碰撞方法,因为你在计时器上调用的碰撞方法与你的得分方法相同。当分数变为1时,它们都会被调用,并且计分方法中没有任何东西会重置游戏