From 7e84858da5ecb1a445982860ce177c3c91318135 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Thu, 18 Aug 2011 20:06:45 -0400 Subject: 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 --- Classes/GameModeSelection.h | 2 +- Classes/GameModeSelection.m | 38 ++++++++++++++++++++++++++++++++++---- Classes/TutorialMode.m | 4 ++-- 3 files changed, 37 insertions(+), 7 deletions(-) (limited to 'Classes') 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 @@ NSString* unlockCondition; CCLabelBMFont* nameLabel; - CCSprite* picture; CCLabelBMFont* otherLabel; } @@ -26,5 +25,6 @@ @property (nonatomic,assign) int highscore; @property (nonatomic,retain) NSString* unlockCondition; - (id)initWithName:(NSString*)name location:(NSString*)location filename:(NSString*)filename unlocked:(BOOL)unlocked; +- (void)buttonTapped; @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 @@ // #import "GameModeSelection.h" +#import "TutorialMode.h" +#import "ClassicGameMode.h" @implementation GameModeSelection @@ -51,11 +53,28 @@ UIGraphicsPopContext(); CGImageRef innerPictureRef = [UIGraphicsGetImageFromCurrentImageContext() CGImage]; - UIGraphicsEndImageContext(); - picture = [CCSprite spriteWithCGImage:innerPictureRef key:filename]; - picture.position = ccp(0, 32); - [self addChild:picture]; + if (unlocked) + { + CCSprite* picture = [CCSprite spriteWithCGImage:innerPictureRef key:[NSString stringWithFormat:@"gms-%@", filename]]; + UIGraphicsPushContext(context); + CGContextSetFillColorWithColor(context, [[UIColor colorWithRed:0 green:0 blue:0 alpha:0.5] CGColor]); + CGContextFillRect(context, CGRectMake(0, 0, 128, 128)); + UIGraphicsPopContext(); + CGImageRef selectedButtonRef = [UIGraphicsGetImageFromCurrentImageContext() CGImage]; + CCSprite* selectedButton = [CCSprite spriteWithCGImage:selectedButtonRef key:[NSString stringWithFormat:@"gms-%@-selected", filename]]; + + CCMenuItemSprite* pictureMenuItem = [CCMenuItemSprite itemFromNormalSprite:picture selectedSprite:selectedButton target:self selector:@selector(buttonTapped)]; + CCMenu* theMenu = [CCMenu menuWithItems:pictureMenuItem, nil]; + theMenu.position = ccp(0, 32); + [self addChild:theMenu]; + } else { + CCSprite* picture = [CCSprite spriteWithCGImage:innerPictureRef key:[NSString stringWithFormat:@"gms-%@-locked", filename]]; + picture.position = ccp(0, 32); + [self addChild:picture]; + } + + UIGraphicsEndImageContext(); } return self; @@ -85,4 +104,15 @@ } } +- (void)buttonTapped +{ + if ([name isEqual:@"Tutorial"]) + { + [[CCDirector sharedDirector] replaceScene:[TutorialMode scene]]; + } else if ([name isEqual:@"Collect"]) + { + [[CCDirector sharedDirector] replaceScene:[ClassicGameMode scene]]; + } +} + @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 @@ #import "Bottle.h" #import "OneUp.h" #import "Rock.h" -#import "MainMenuLayer.h" +#import "GameModeSelectionLayer.h" // Item tags: // 2000 - first dropped item @@ -227,7 +227,7 @@ [self schedule:@selector(randomlyAddObject:) interval:1.0f]; } else if ([currentTutorial.name isEqual:@"end"]) { - [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:3.0f scene:[MainMenuLayer scene] withColor:ccc3(0,0,0)]]; + [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:3.0f scene:[GameModeSelectionLayer scene] withColor:ccc3(0,0,0)]]; } self.currentTutorial = nil; -- cgit 1.4.1