From 3750d7aa4e307d1f2099eceaa21014151e78d364 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Thu, 18 Aug 2011 15:51:48 -0400 Subject: Started game mode selection screen So far, tapping "New Game" shows a screen with two game modes: the tutorial and the classic collect. They both have pictures and Collect's is grayscale if it hasn't been unlocked yet (a.k.a. the tutorial hasn't been completed yet). Also, Collect's title is replaced with question marks and the text "Beat the tutorial!" is shown if it isn't unlocked--if it is unlocked, the player's highscore, if they have one, is shown. A "Back to Main Menu" button is also present. Neither selection is as of yet tappable, and neither picture yet has a border. You cannot scroll through modes yet either. Refs #207 --- Classes/GameModeSelection.m | 88 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 Classes/GameModeSelection.m (limited to 'Classes/GameModeSelection.m') diff --git a/Classes/GameModeSelection.m b/Classes/GameModeSelection.m new file mode 100644 index 0000000..56e65d9 --- /dev/null +++ b/Classes/GameModeSelection.m @@ -0,0 +1,88 @@ +// +// GameModeSelection.m +// Cartographic +// +// Created by Starla Insigna on 8/18/11. +// Copyright 2011 Four Island. All rights reserved. +// + +#import "GameModeSelection.h" + +@implementation GameModeSelection + +@synthesize name, location, unlocked, highscore, unlockCondition; + +- (id)initWithName:(NSString*)m_name location:(NSString*)m_location filename:(NSString*)filename unlocked:(BOOL)m_unlocked; +{ + self = [super init]; + + if (nil != self) + { + self.anchorPoint = CGPointMake(0.5f, 0.5f); + + name = m_name; + location = m_location; + unlocked = m_unlocked; + + if (!unlocked) + { + name = [@"" stringByPaddingToLength:name.length withString:@"?" startingAtIndex:0]; + location = [@"" stringByPaddingToLength:location.length withString:@"?" startingAtIndex:0]; + } + + nameLabel = [CCLabelBMFont labelWithString:[NSString stringWithFormat:@"%@ (%@)", location, name] fntFile:@"levelnames.fnt"]; + + [self addChild:nameLabel]; + nameLabel.position = ccp(0, -32-nameLabel.contentSize.height); + + UIImage* innerPicture = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:filename ofType:@"png"]]; + UIGraphicsBeginImageContext(CGSizeMake(128, 128)); + CGContextRef context = UIGraphicsGetCurrentContext(); + UIGraphicsPushContext(context); + + if (unlocked) + { + [innerPicture drawInRect:CGRectMake(0, 0, 128, 128)]; + } else { + CGContextSetFillColorWithColor(context, [[UIColor whiteColor] CGColor]); + CGContextFillRect(context, CGRectMake(0, 0, 128, 128)); + [innerPicture drawInRect:CGRectMake(0, 0, 128, 128) blendMode:kCGBlendModeLuminosity alpha:1.0]; + } + + UIGraphicsPopContext(); + CGImageRef innerPictureRef = [UIGraphicsGetImageFromCurrentImageContext() CGImage]; + UIGraphicsEndImageContext(); + + picture = [CCSprite spriteWithCGImage:innerPictureRef key:filename]; + picture.position = ccp(0, 32); + [self addChild:picture]; + } + + return self; +} + +- (void)setHighscore:(int)m_highscore +{ + if (unlocked) + { + highscore = m_highscore; + + otherLabel = [CCLabelBMFont labelWithString:[NSString stringWithFormat:@"Highscore: %d", highscore] fntFile:@"leveldescriptions.fnt"]; + otherLabel.position = ccp(0, -32-nameLabel.contentSize.height-otherLabel.contentSize.height); + [self addChild:otherLabel]; + } +} + +- (void)setUnlockCondition:(NSString *)m_unlockCondition +{ + if (!unlocked) + { + unlockCondition = m_unlockCondition; + + otherLabel = [CCLabelBMFont labelWithString:unlockCondition fntFile:@"leveldescriptions.fnt"]; + otherLabel.position = ccp(0, -32-nameLabel.contentSize.height-otherLabel.contentSize.height); + [self addChild:otherLabel]; + } +} + +@end -- cgit 1.4.1