I'm using cocos2d to create a DNA themed Flappy Bird style game (long story, don't expect to make any money off of it). I'm trying to create a system of rewarding a "medal" based on the score reached on a certain round. I'm using and greater than and less than methods to indicate whether or not a certain "medal" should be received. However, all of my medals show up at the same time instead of individually based on score. Here is the applicable code:
NSInteger _points;
-(BOOL)ccPhysicsCollisionBegin:(CCPhysicsCollisionPair *)pair hero:(CCNode *)hero goal:(CCNode *)goal {
[goal removeFromParent];
_points++;
_scoreLabel.string = [NSString stringWithFormat:@"%d", _points];
[self saveState];
[self loadSavedState];
if (_points > _highScore) {
_highScore = _points;
}
return TRUE;
}
- (void)gameOver {
if (!_gameOver) {
_scrollSpeed = 0.f;
_gameOver = TRUE;
_restartButton.visible = TRUE;
_menuButton.visible = TRUE;
_gameOverText.visible = TRUE;
_score.visible = TRUE;
_highScoreValue.visible = TRUE;
_highScoreLabel.visible = TRUE;
_medal.visible = TRUE;
if (9 < _points < 20) {
_uracil.visible = TRUE;
_uracilLabel.visible = TRUE;
}
if (19 < _points < 30) {
_thymine.visible = TRUE;
_thymineLabel.visible = TRUE;
}
if (29 < _points < 40) {
_cytosine.visible = TRUE;
_cytosineLabel.visible = TRUE;
}
if (39 < _points < 50) {
_guanine.visible = TRUE;
_guanineLabel.visible = TRUE;
}
if (49 < _points < 60) {
_adenine.visible = TRUE;
_adenineLabel.visible = TRUE;
}
_scoreLabel.position = ccp(260, 358);
_hero.physicsBody.allowsRotation = FALSE;
[_hero stopAllActions];
CCActionMoveBy *moveBy = [CCActionMoveBy actionWithDuration:0.2f position:ccp(-5, 5)];
CCActionInterval *reverseMovement = [moveBy reverse];
CCActionSequence *shakeSequence = [CCActionSequence actionWithArray:@[moveBy, reverseMovement]];
CCActionEaseBounce *bounce = [CCActionEaseBounce actionWithAction:shakeSequence];
[self runAction:bounce];
}
}
How can I make it so that the "medals" show up when they are supposed to based on score? Thanks for the help.
Replace these
if (9 < _points < 20)
With
if (_points > 9 && _points < 20)