diff options
author | Starla Insigna <starla4444@gmail.com> | 2011-08-18 15:51:48 -0400 |
---|---|---|
committer | Starla Insigna <starla4444@gmail.com> | 2011-08-18 15:51:48 -0400 |
commit | 3750d7aa4e307d1f2099eceaa21014151e78d364 (patch) | |
tree | 77487a1cc5fd055d2d8096a158d4908a5e4094fa /Classes/GameModeSelection.m | |
parent | 6906cf0ce4f8266173d67a7b9fccc56747d5d618 (diff) | |
download | cartcollect-3750d7aa4e307d1f2099eceaa21014151e78d364.tar.gz cartcollect-3750d7aa4e307d1f2099eceaa21014151e78d364.tar.bz2 cartcollect-3750d7aa4e307d1f2099eceaa21014151e78d364.zip |
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
Diffstat (limited to 'Classes/GameModeSelection.m')
-rw-r--r-- | Classes/GameModeSelection.m | 88 |
1 files changed, 88 insertions, 0 deletions
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 @@ | |||
1 | // | ||
2 | // GameModeSelection.m | ||
3 | // Cartographic | ||
4 | // | ||
5 | // Created by Starla Insigna on 8/18/11. | ||
6 | // Copyright 2011 Four Island. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import "GameModeSelection.h" | ||
10 | |||
11 | @implementation GameModeSelection | ||
12 | |||
13 | @synthesize name, location, unlocked, highscore, unlockCondition; | ||
14 | |||
15 | - (id)initWithName:(NSString*)m_name location:(NSString*)m_location filename:(NSString*)filename unlocked:(BOOL)m_unlocked; | ||
16 | { | ||
17 | self = [super init]; | ||
18 | |||
19 | if (nil != self) | ||
20 | { | ||
21 | self.anchorPoint = CGPointMake(0.5f, 0.5f); | ||
22 | |||
23 | name = m_name; | ||
24 | location = m_location; | ||
25 | unlocked = m_unlocked; | ||
26 | |||
27 | if (!unlocked) | ||
28 | { | ||
29 | name = [@"" stringByPaddingToLength:name.length withString:@"?" startingAtIndex:0]; | ||
30 | location = [@"" stringByPaddingToLength:location.length withString:@"?" startingAtIndex:0]; | ||
31 | } | ||
32 | |||
33 | nameLabel = [CCLabelBMFont labelWithString:[NSString stringWithFormat:@"%@ (%@)", location, name] fntFile:@"levelnames.fnt"]; | ||
34 | |||
35 | [self addChild:nameLabel]; | ||
36 | nameLabel.position = ccp(0, -32-nameLabel.contentSize.height); | ||
37 | |||
38 | UIImage* innerPicture = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:filename ofType:@"png"]]; | ||
39 | UIGraphicsBeginImageContext(CGSizeMake(128, 128)); | ||
40 | CGContextRef context = UIGraphicsGetCurrentContext(); | ||
41 | UIGraphicsPushContext(context); | ||
42 | |||
43 | if (unlocked) | ||
44 | { | ||
45 | [innerPicture drawInRect:CGRectMake(0, 0, 128, 128)]; | ||
46 | } else { | ||
47 | CGContextSetFillColorWithColor(context, [[UIColor whiteColor] CGColor]); | ||
48 | CGContextFillRect(context, CGRectMake(0, 0, 128, 128)); | ||
49 | [innerPicture drawInRect:CGRectMake(0, 0, 128, 128) blendMode:kCGBlendModeLuminosity alpha:1.0]; | ||
50 | } | ||
51 | |||
52 | UIGraphicsPopContext(); | ||
53 | CGImageRef innerPictureRef = [UIGraphicsGetImageFromCurrentImageContext() CGImage]; | ||
54 | UIGraphicsEndImageContext(); | ||
55 | |||
56 | picture = [CCSprite spriteWithCGImage:innerPictureRef key:filename]; | ||
57 | picture.position = ccp(0, 32); | ||
58 | [self addChild:picture]; | ||
59 | } | ||
60 | |||
61 | return self; | ||
62 | } | ||
63 | |||
64 | - (void)setHighscore:(int)m_highscore | ||
65 | { | ||
66 | if (unlocked) | ||
67 | { | ||
68 | highscore = m_highscore; | ||
69 | |||
70 | otherLabel = [CCLabelBMFont labelWithString:[NSString stringWithFormat:@"Highscore: %d", highscore] fntFile:@"leveldescriptions.fnt"]; | ||
71 | otherLabel.position = ccp(0, -32-nameLabel.contentSize.height-otherLabel.contentSize.height); | ||
72 | [self addChild:otherLabel]; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | - (void)setUnlockCondition:(NSString *)m_unlockCondition | ||
77 | { | ||
78 | if (!unlocked) | ||
79 | { | ||
80 | unlockCondition = m_unlockCondition; | ||
81 | |||
82 | otherLabel = [CCLabelBMFont labelWithString:unlockCondition fntFile:@"leveldescriptions.fnt"]; | ||
83 | otherLabel.position = ccp(0, -32-nameLabel.contentSize.height-otherLabel.contentSize.height); | ||
84 | [self addChild:otherLabel]; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | @end | ||