summary refs log tree commit diff stats
path: root/Classes/GameModeSelection.m
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2011-08-18 20:06:45 -0400
committerStarla Insigna <starla4444@gmail.com>2011-08-18 20:06:45 -0400
commit7e84858da5ecb1a445982860ce177c3c91318135 (patch)
treea742e9f4418eb71f073bb20de3021438d345927f /Classes/GameModeSelection.m
parent3750d7aa4e307d1f2099eceaa21014151e78d364 (diff)
downloadcartcollect-7e84858da5ecb1a445982860ce177c3c91318135.tar.gz
cartcollect-7e84858da5ecb1a445982860ce177c3c91318135.tar.bz2
cartcollect-7e84858da5ecb1a445982860ce177c3c91318135.zip
Made game mode selections tappable
Both the Tutorial and Collect game mode selections can now be tapped to start playing the mode. Holding your finger down on a game mode darkens the image, to give the player feedback on the fact that they are touching a button. This only applies to unlocked game modes--not-yet-unlocked game modes are just sprites, not buttons, and do not react to touch. Note that the game mode does not yet transition in with the zoom in/fade in transition combo that is specified in the ticket.

Also fixed a bug that would, if the player hadn't yet unlocked Collect and then played the Tutorial, continue to show the grayscale Collect image even though the button was completely working and tappable.

Also changed Tutorial Mode to bring the player to the game mode selection screen upon completion instead of the main menu.

Refs #207
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