Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

trey5498

macrumors regular
Original poster
Jun 16, 2008
191
0
I am currently attempting to complete a school project that uses SpriteKit. Since we are not given much time we were asked to create or modify the existing one from the book (Archer hitting balloons). I have successfully created a score hud display and I want to add the balls left to drop.

Here is what is in the book,

Code:
SKAction *releaseBalls = [SKAction sequence:@[[SKAction performSelector:@selector(createBallNode) onTarget:self], [SKAction waitForDuration:1]]];

    [self runAction: [SKAction repeatAction:releaseBalls count:self.ballCount] completion:^{
        [self gameOver];
    }];

What I am trying:

Code:
_ballsLeft = 40;
while (_ballsLeft <0)
{
     [self runAction:releaseBalls completion:^{
        [self gameOver];
    }];
    _ballsLeft--;
    _ballsLeftLabel.text = [NSString stringWithFormat:@"Balls Left: %04d", _ballLeft];
}

I am sure there is a better way to accomplish this, especially since mine does update or drop any balls.

Can anyone help?
 

chown33

Moderator
Staff member
Aug 9, 2009
10,761
8,459
A sea of green
What I am trying:
Code:
[COLOR="Red"]_ballsLeft = 40;
while (_ballsLeft <0)
[/COLOR]{
     [self runAction:releaseBalls completion:^{
        [self gameOver];
    }];
    _ballsLeft--;
    _ballsLeftLabel.text = [NSString stringWithFormat:@"Balls Left: %04d", _ballLeft];
}

I am sure there is a better way to accomplish this, especially since mine does update or drop any balls.

Can anyone help?

Think very carefully about what the red-hilited statements mean. Pay particular attention to the condition of the 'while'. Step through it using pencil and paper if necessary.
 

trey5498

macrumors regular
Original poster
Jun 16, 2008
191
0
Think very carefully about what the red-hilited statements mean. Pay particular attention to the condition of the 'while'. Step through it using pencil and paper if necessary.


Sorry that was a typo supposed to be while (_ballsLeft > 0).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.