From 1b5dccf63ed1d442e7d8e7538f2adfe07351dfaf Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Tue, 23 Aug 2011 12:25:08 -0400 Subject: Reorganized level selection layer I'm not really sure how, though I suspect it has something to do with the onEnterTransitionDidFinish and onExit methods, but this seems to fix the bug in which tapping on Collect immediately after playing Tutorial would cause Tutorial to play again. Fixes #208 --- Classes/GameModeSelectionLayer.m | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Classes/GameModeSelectionLayer.m b/Classes/GameModeSelectionLayer.m index ad6a455..7b97e11 100644 --- a/Classes/GameModeSelectionLayer.m +++ b/Classes/GameModeSelectionLayer.m @@ -38,10 +38,8 @@ if (nil != self) { - gameModes = [[NSMutableArray alloc] init]; - CCMenu* menu = [CCMenu menuWithItems:nil]; NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; - float onePanelWide = 128; + gameModes = [[NSMutableArray alloc] init]; GameModeSelection* tutorialSelection = [GameModeSelection selectionWithName:@"Tutorial" location:@"Florence" filename:@"florence" unlocked:YES]; [gameModes addObject:tutorialSelection]; @@ -69,6 +67,8 @@ [gameModes addObject:collectSelection]; + CCMenu* menu = [CCMenu menuWithItems:nil]; + float onePanelWide = 128; float padding = 15; float totalPanelWidth = onePanelWide + padding*2; float numberOfPanels = [gameModes count]; @@ -90,15 +90,12 @@ pageControl.numberOfPages = numberOfPanels; pageControl.currentPage = currentWorldOffset; pageControl.frame = CGRectMake(0, 250, 480, 20); - [[[CCDirector sharedDirector] openGLView] addSubview:pageControl]; menu.position = ccpAdd(menu.position, ccp(totalWidth/2 - totalPanelWidth/2, 320)); touchDelegatingView = [[TouchDelegatingView alloc] initWithFrame:CGRectMake(0, 0, 480, 320)]; scrollView = [[CocosOverlayScrollView alloc] initWithFrame:CGRectMake(0, 0, totalPanelWidth, 320) numPages:numberOfPanels width:totalPanelWidth layer:panels pageControl:pageControl]; touchDelegatingView.scrollView = scrollView; [scrollView setContentOffset:CGPointMake(currentWorldOffset*totalPanelWidth+1,0) animated:NO]; - [[[CCDirector sharedDirector] openGLView] addSubview:touchDelegatingView]; - [[[CCDirector sharedDirector] openGLView] addSubview:scrollView]; CCMenuItemImage* newgameMenuItem = [CCMenuItemImage itemFromNormalImage:@"back.png" selectedImage:@"back2.png" target:self selector:@selector(mainmenu)]; CCMenu* myMenu = [CCMenu menuWithItems:newgameMenuItem, nil]; @@ -109,8 +106,19 @@ return self; } +- (void)onEnterTransitionDidFinish +{ + [super onEnterTransitionDidFinish]; + + [[[CCDirector sharedDirector] openGLView] addSubview:pageControl]; + [[[CCDirector sharedDirector] openGLView] addSubview:touchDelegatingView]; + [[[CCDirector sharedDirector] openGLView] addSubview:scrollView]; +} + - (void)onExit { + [super onExit]; + [touchDelegatingView removeFromSuperview]; [scrollView removeFromSuperview]; [pageControl removeFromSuperview]; -- cgit 1.4.1