From fe7ec5e55f609e628932c65d3f0bfe4948c9d023 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Fri, 4 Jan 2013 13:18:54 -0500 Subject: Added stars to selection screen Closes #231 --- Classes/GameModeSelection.m | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Classes/GameModeSelection.m b/Classes/GameModeSelection.m index ea5f45b..3c495df 100644 --- a/Classes/GameModeSelection.m +++ b/Classes/GameModeSelection.m @@ -119,6 +119,33 @@ theMenu.position = ccp(-5, 0); [self addChild:theMenu]; + // Render the stars + UIImage* bronzeStar = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"star_1" ofType:@"png"]]; + UIImage* silverStar = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"star_2" ofType:@"png"]]; + UIImage* goldStar = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"star_3" ofType:@"png"]]; + + UIGraphicsBeginImageContext(CGSizeMake(boxSize.width-12, boxSize.height-12)); + if ((gameMode.numOfStars >= 1) && ([gameMode star:0])) + { + [bronzeStar drawInRect:CGRectMake(8, 0, 32, 32)]; + } + + if ((gameMode.numOfStars >= 2) && ([gameMode star:1])) + { + [silverStar drawInRect:CGRectMake(48, 0, 32, 32)]; + } + + if ((gameMode.numOfStars >= 3) && ([gameMode star:2])) + { + [goldStar drawInRect:CGRectMake(88, 0, 32, 32)]; + } + + CGImageRef starsRef = [UIGraphicsGetImageFromCurrentImageContext() CGImage]; + UIGraphicsEndImageContext(); + CCSprite* starsSprite = [CCSprite spriteWithCGImage:starsRef key:[NSString stringWithFormat:@"gms-%@-star%d", name, gameMode.starsCollected]]; + starsSprite.position = ccp(0, 8); + [self addChild:starsSprite]; + // Render the titles UIFont* titleFont = [UIFont fontWithName:@"AmericanTypewriter-Bold" size:18.0f]; CGSize titleSize = [location sizeWithFont:titleFont constrainedToSize:CGSizeMake(128, 0)]; -- cgit 1.4.1