summary refs log tree commit diff stats
path: root/Classes/GameModeSelection.m
diff options
context:
space:
mode:
Diffstat (limited to 'Classes/GameModeSelection.m')
-rw-r--r--Classes/GameModeSelection.m38
1 files changed, 34 insertions, 4 deletions
diff --git a/Classes/GameModeSelection.m b/Classes/GameModeSelection.m index 56e65d9..0816828 100644 --- a/Classes/GameModeSelection.m +++ b/Classes/GameModeSelection.m
@@ -7,6 +7,8 @@
7// 7//
8 8
9#import "GameModeSelection.h" 9#import "GameModeSelection.h"
10#import "TutorialMode.h"
11#import "ClassicGameMode.h"
10 12
11@implementation GameModeSelection 13@implementation GameModeSelection
12 14
@@ -51,11 +53,28 @@
51 53
52 UIGraphicsPopContext(); 54 UIGraphicsPopContext();
53 CGImageRef innerPictureRef = [UIGraphicsGetImageFromCurrentImageContext() CGImage]; 55 CGImageRef innerPictureRef = [UIGraphicsGetImageFromCurrentImageContext() CGImage];
54 UIGraphicsEndImageContext();
55 56
56 picture = [CCSprite spriteWithCGImage:innerPictureRef key:filename]; 57 if (unlocked)
57 picture.position = ccp(0, 32); 58 {
58 [self addChild:picture]; 59 CCSprite* picture = [CCSprite spriteWithCGImage:innerPictureRef key:[NSString stringWithFormat:@"gms-%@", filename]];
60 UIGraphicsPushContext(context);
61 CGContextSetFillColorWithColor(context, [[UIColor colorWithRed:0 green:0 blue:0 alpha:0.5] CGColor]);
62 CGContextFillRect(context, CGRectMake(0, 0, 128, 128));
63 UIGraphicsPopContext();
64 CGImageRef selectedButtonRef = [UIGraphicsGetImageFromCurrentImageContext() CGImage];
65 CCSprite* selectedButton = [CCSprite spriteWithCGImage:selectedButtonRef key:[NSString stringWithFormat:@"gms-%@-selected", filename]];
66
67 CCMenuItemSprite* pictureMenuItem = [CCMenuItemSprite itemFromNormalSprite:picture selectedSprite:selectedButton target:self selector:@selector(buttonTapped)];
68 CCMenu* theMenu = [CCMenu menuWithItems:pictureMenuItem, nil];
69 theMenu.position = ccp(0, 32);
70 [self addChild:theMenu];
71 } else {
72 CCSprite* picture = [CCSprite spriteWithCGImage:innerPictureRef key:[NSString stringWithFormat:@"gms-%@-locked", filename]];
73 picture.position = ccp(0, 32);
74 [self addChild:picture];
75 }
76
77 UIGraphicsEndImageContext();
59 } 78 }
60 79
61 return self; 80 return self;
@@ -85,4 +104,15 @@
85 } 104 }
86} 105}
87 106
107- (void)buttonTapped
108{
109 if ([name isEqual:@"Tutorial"])
110 {
111 [[CCDirector sharedDirector] replaceScene:[TutorialMode scene]];
112 } else if ([name isEqual:@"Collect"])
113 {
114 [[CCDirector sharedDirector] replaceScene:[ClassicGameMode scene]];
115 }
116}
117
88@end 118@end