summary refs log tree commit diff stats
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
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
-rw-r--r--Classes/GameModeSelection.h2
-rw-r--r--Classes/GameModeSelection.m38
-rw-r--r--Classes/TutorialMode.m4
3 files changed, 37 insertions, 7 deletions
diff --git a/Classes/GameModeSelection.h b/Classes/GameModeSelection.h index aadbf36..66d0a5a 100644 --- a/Classes/GameModeSelection.h +++ b/Classes/GameModeSelection.h
@@ -16,7 +16,6 @@
16 NSString* unlockCondition; 16 NSString* unlockCondition;
17 17
18 CCLabelBMFont* nameLabel; 18 CCLabelBMFont* nameLabel;
19 CCSprite* picture;
20 CCLabelBMFont* otherLabel; 19 CCLabelBMFont* otherLabel;
21} 20}
22 21
@@ -26,5 +25,6 @@
26@property (nonatomic,assign) int highscore; 25@property (nonatomic,assign) int highscore;
27@property (nonatomic,retain) NSString* unlockCondition; 26@property (nonatomic,retain) NSString* unlockCondition;
28- (id)initWithName:(NSString*)name location:(NSString*)location filename:(NSString*)filename unlocked:(BOOL)unlocked; 27- (id)initWithName:(NSString*)name location:(NSString*)location filename:(NSString*)filename unlocked:(BOOL)unlocked;
28- (void)buttonTapped;
29 29
30@end 30@end
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
diff --git a/Classes/TutorialMode.m b/Classes/TutorialMode.m index c28bd08..1285597 100644 --- a/Classes/TutorialMode.m +++ b/Classes/TutorialMode.m
@@ -12,7 +12,7 @@
12#import "Bottle.h" 12#import "Bottle.h"
13#import "OneUp.h" 13#import "OneUp.h"
14#import "Rock.h" 14#import "Rock.h"
15#import "MainMenuLayer.h" 15#import "GameModeSelectionLayer.h"
16 16
17// Item tags: 17// Item tags:
18// 2000 - first dropped item 18// 2000 - first dropped item
@@ -227,7 +227,7 @@
227 [self schedule:@selector(randomlyAddObject:) interval:1.0f]; 227 [self schedule:@selector(randomlyAddObject:) interval:1.0f];
228 } else if ([currentTutorial.name isEqual:@"end"]) 228 } else if ([currentTutorial.name isEqual:@"end"])
229 { 229 {
230 [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:3.0f scene:[MainMenuLayer scene] withColor:ccc3(0,0,0)]]; 230 [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:3.0f scene:[GameModeSelectionLayer scene] withColor:ccc3(0,0,0)]];
231 } 231 }
232 232
233 self.currentTutorial = nil; 233 self.currentTutorial = nil;