From fee8d3506b4c2f6d5933a85181de9bb8e6f5fcc4 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Wed, 17 Aug 2011 12:54:22 -0400 Subject: Made tutorial replayable Closes #202 --- Classes/MainMenuLayer.h | 1 + Classes/MainMenuLayer.m | 21 ++++++++++----------- Classes/TutorialMode.h | 1 - Classes/TutorialMode.m | 23 ++--------------------- 4 files changed, 13 insertions(+), 33 deletions(-) (limited to 'Classes') diff --git a/Classes/MainMenuLayer.h b/Classes/MainMenuLayer.h index d8483b3..e43c5e1 100755 --- a/Classes/MainMenuLayer.h +++ b/Classes/MainMenuLayer.h @@ -16,6 +16,7 @@ + (CCScene*)scene; - (id)init; - (void)newgame; +- (void)tutorial; - (void)highscores; @end diff --git a/Classes/MainMenuLayer.m b/Classes/MainMenuLayer.m index 50c595f..537c5c1 100755 --- a/Classes/MainMenuLayer.m +++ b/Classes/MainMenuLayer.m @@ -44,10 +44,11 @@ //CCLabelBMFont* menuItemLabel2 = [CCLabelBMFont labelWithString:@"Highscores" fntFile:@"getoffthatboatrightnowyounglady.fnt"]; //CCMenuItemLabel* menuItem2 = [CCMenuItemLabel itemWithLabel:menuItemLabel2 target:self selector:@selector(highscores)]; - CCMenuItemImage* menuItem1 = [CCMenuItemImage itemFromNormalImage:@"newgame.png" selectedImage:@"newgame2.png" target:self selector:@selector(newgame)]; - CCMenuItemImage* menuItem2 = [CCMenuItemImage itemFromNormalImage:@"highscores.png" selectedImage:@"highscores2.png" target:self selector:@selector(highscores)]; + CCMenuItemImage* newgameMenuItem = [CCMenuItemImage itemFromNormalImage:@"newgame.png" selectedImage:@"newgame2.png" target:self selector:@selector(newgame)]; + CCMenuItemImage* tutorialMenuItem = [CCMenuItemImage itemFromNormalImage:@"tutorial.png" selectedImage:@"tutorial2.png" target:self selector:@selector(tutorial)]; + CCMenuItemImage* highscoresMenuItem = [CCMenuItemImage itemFromNormalImage:@"highscores.png" selectedImage:@"highscores2.png" target:self selector:@selector(highscores)]; - CCMenu* menu = [CCMenu menuWithItems:menuItem1, menuItem2, nil]; + CCMenu* menu = [CCMenu menuWithItems:newgameMenuItem, tutorialMenuItem, highscoresMenuItem, nil]; [menu alignItemsVertically]; menu.position = ccp(240, 100); [self addChild:menu]; @@ -58,14 +59,12 @@ - (void)newgame { - NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; - - if ([defaults boolForKey:@"hasDoneTutorial"]) - { - [[CCDirector sharedDirector] replaceScene:[ClassicGameMode scene]]; - } else { - [[CCDirector sharedDirector] replaceScene:[TutorialMode scene]]; - } + [[CCDirector sharedDirector] replaceScene:[ClassicGameMode scene]]; +} + +- (void)tutorial +{ + [[CCDirector sharedDirector] replaceScene:[TutorialMode scene]]; } - (void)highscores diff --git a/Classes/TutorialMode.h b/Classes/TutorialMode.h index 17b0c7f..6380483 100644 --- a/Classes/TutorialMode.h +++ b/Classes/TutorialMode.h @@ -21,6 +21,5 @@ - (FallingObject*)dropSpecificItem:(FallingObject*)item; - (FallingObject*)dropRandomItem; - (void)randomlyAddObject:(ccTime)dt; -- (void)skipTutorial; @end diff --git a/Classes/TutorialMode.m b/Classes/TutorialMode.m index 37e8bd0..ed51648 100644 --- a/Classes/TutorialMode.m +++ b/Classes/TutorialMode.m @@ -12,7 +12,7 @@ #import "Bottle.h" #import "OneUp.h" #import "Rock.h" -#import "ClassicGameMode.h" +#import "MainMenuLayer.h" // Item tags: // 2000 - first dropped item @@ -35,11 +35,6 @@ backgroundImage.position = ccp(240, 160); [self addChild:backgroundImage z:-1]; - CCMenuItemImage* menuItem1 = [CCMenuItemImage itemFromNormalImage:@"skiptutorial.png" selectedImage:@"skiptutorial2.png" target:self selector:@selector(skipTutorial)]; - CCMenu* theMenu = [CCMenu menuWithItems:menuItem1, nil]; - theMenu.position = ccp(480-16-16-62, 320-8-16); - [self addChild:theMenu]; - showedDeathBubble = NO; randomItemsDropped = 0; } @@ -201,10 +196,7 @@ [self schedule:@selector(randomlyAddObject:) interval:1.0f]; } else if ([currentTutorial.name isEqual:@"end"]) { - NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; - [defaults setBool:YES forKey:@"hasDoneTutorial"]; - - [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:3.0f scene:[ClassicGameMode scene] withColor:ccc3(0,0,0)]]; + [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:3.0f scene:[MainMenuLayer scene] withColor:ccc3(0,0,0)]]; } self.currentTutorial = nil; @@ -335,15 +327,4 @@ randomItemsDropped++; } -- (void)skipTutorial -{ - [self unscheduleAllSelectors]; - self.currentTutorial = nil; - - NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; - [defaults setBool:YES forKey:@"hasDoneTutorial"]; - - [[CCDirector sharedDirector] replaceScene:[CCTransitionFlipY transitionWithDuration:1.0f scene:[ClassicGameMode scene]]]; -} - @end -- cgit 1.4.1