I am trying to get an 'if statement' to work.
Basically, what it is meant to do is if you score more than 500,000 points, it shows a sprite saying "You Win!" And, if you score less than this, it will show one saying "You lose!" But, basically, it will only show the 'You Win!' sprite even if you get 0 points.
The code is shown below:
-(void)youLose
{
if (score < 500,000)
{
CCSprite * lose = [CCSprite spriteWithFile:@"lose.png"];
[self addChild:lose z:3];
[lose setPosition:ccp(240, 160)];
[lose setOpacity:0];
[lose runAction:[CCSequence actions:[CCDelayTime actionWithDuration:0.4],
[CCSpawn actions:[CCFadeIn actionWithDuration:0.4],
[CCScaleTo actionWithDuration:3 scale:1.2],nil],
[CCDelayTime actionWithDuration:5],
[CCFadeOut actionWithDuration:1],
[CCCallFuncN actionWithTarget:self selector:@selector(removeSprite:)],nil]];
}
else
{
CCSprite * win = [CCSprite spriteWithFile:@"youWin.png"];
[self addChild:win z:3];
[win setPosition:ccp(240, 160)];
[win setOpacity:0];
[win runAction:[CCSequence actions:[CCDelayTime actionWithDuration:0.4],
[CCSpawn actions:[CCFadeIn actionWithDuration:0.4],
[CCScaleTo actionWithDuration:3 scale:1.2],nil],
[CCDelayTime actionWithDuration:5],
[CCFadeOut actionWithDuration:1],
[CCCallFuncN actionWithTarget:self selector:@selector(removeSprite:)],nil]];
}
}
Thanks,
Ryan