summary refs log tree commit diff stats
path: root/Classes/GameModeSelectionLayer.m
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2011-08-23 12:25:08 -0400
committerStarla Insigna <starla4444@gmail.com>2011-08-23 12:25:08 -0400
commit1b5dccf63ed1d442e7d8e7538f2adfe07351dfaf (patch)
treed4ab2eb6d76746b2c61db4d018af4619998ca143 /Classes/GameModeSelectionLayer.m
parent887e595136e71f52ea585f17d73e5ac3baefb7eb (diff)
downloadcartcollect-1b5dccf63ed1d442e7d8e7538f2adfe07351dfaf.tar.gz
cartcollect-1b5dccf63ed1d442e7d8e7538f2adfe07351dfaf.tar.bz2
cartcollect-1b5dccf63ed1d442e7d8e7538f2adfe07351dfaf.zip
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
Diffstat (limited to 'Classes/GameModeSelectionLayer.m')
-rw-r--r--Classes/GameModeSelectionLayer.m20
1 files 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 @@
38 38
39 if (nil != self) 39 if (nil != self)
40 { 40 {
41 gameModes = [[NSMutableArray alloc] init];
42 CCMenu* menu = [CCMenu menuWithItems:nil];
43 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; 41 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
44 float onePanelWide = 128; 42 gameModes = [[NSMutableArray alloc] init];
45 43
46 GameModeSelection* tutorialSelection = [GameModeSelection selectionWithName:@"Tutorial" location:@"Florence" filename:@"florence" unlocked:YES]; 44 GameModeSelection* tutorialSelection = [GameModeSelection selectionWithName:@"Tutorial" location:@"Florence" filename:@"florence" unlocked:YES];
47 [gameModes addObject:tutorialSelection]; 45 [gameModes addObject:tutorialSelection];
@@ -69,6 +67,8 @@
69 67
70 [gameModes addObject:collectSelection]; 68 [gameModes addObject:collectSelection];
71 69
70 CCMenu* menu = [CCMenu menuWithItems:nil];
71 float onePanelWide = 128;
72 float padding = 15; 72 float padding = 15;
73 float totalPanelWidth = onePanelWide + padding*2; 73 float totalPanelWidth = onePanelWide + padding*2;
74 float numberOfPanels = [gameModes count]; 74 float numberOfPanels = [gameModes count];
@@ -90,15 +90,12 @@
90 pageControl.numberOfPages = numberOfPanels; 90 pageControl.numberOfPages = numberOfPanels;
91 pageControl.currentPage = currentWorldOffset; 91 pageControl.currentPage = currentWorldOffset;
92 pageControl.frame = CGRectMake(0, 250, 480, 20); 92 pageControl.frame = CGRectMake(0, 250, 480, 20);
93 [[[CCDirector sharedDirector] openGLView] addSubview:pageControl];
94 93
95 menu.position = ccpAdd(menu.position, ccp(totalWidth/2 - totalPanelWidth/2, 320)); 94 menu.position = ccpAdd(menu.position, ccp(totalWidth/2 - totalPanelWidth/2, 320));
96 touchDelegatingView = [[TouchDelegatingView alloc] initWithFrame:CGRectMake(0, 0, 480, 320)]; 95 touchDelegatingView = [[TouchDelegatingView alloc] initWithFrame:CGRectMake(0, 0, 480, 320)];
97 scrollView = [[CocosOverlayScrollView alloc] initWithFrame:CGRectMake(0, 0, totalPanelWidth, 320) numPages:numberOfPanels width:totalPanelWidth layer:panels pageControl:pageControl]; 96 scrollView = [[CocosOverlayScrollView alloc] initWithFrame:CGRectMake(0, 0, totalPanelWidth, 320) numPages:numberOfPanels width:totalPanelWidth layer:panels pageControl:pageControl];
98 touchDelegatingView.scrollView = scrollView; 97 touchDelegatingView.scrollView = scrollView;
99 [scrollView setContentOffset:CGPointMake(currentWorldOffset*totalPanelWidth+1,0) animated:NO]; 98 [scrollView setContentOffset:CGPointMake(currentWorldOffset*totalPanelWidth+1,0) animated:NO];
100 [[[CCDirector sharedDirector] openGLView] addSubview:touchDelegatingView];
101 [[[CCDirector sharedDirector] openGLView] addSubview:scrollView];
102 99
103 CCMenuItemImage* newgameMenuItem = [CCMenuItemImage itemFromNormalImage:@"back.png" selectedImage:@"back2.png" target:self selector:@selector(mainmenu)]; 100 CCMenuItemImage* newgameMenuItem = [CCMenuItemImage itemFromNormalImage:@"back.png" selectedImage:@"back2.png" target:self selector:@selector(mainmenu)];
104 CCMenu* myMenu = [CCMenu menuWithItems:newgameMenuItem, nil]; 101 CCMenu* myMenu = [CCMenu menuWithItems:newgameMenuItem, nil];
@@ -109,8 +106,19 @@
109 return self; 106 return self;
110} 107}
111 108
109- (void)onEnterTransitionDidFinish
110{
111 [super onEnterTransitionDidFinish];
112
113 [[[CCDirector sharedDirector] openGLView] addSubview:pageControl];
114 [[[CCDirector sharedDirector] openGLView] addSubview:touchDelegatingView];
115 [[[CCDirector sharedDirector] openGLView] addSubview:scrollView];
116}
117
112- (void)onExit 118- (void)onExit
113{ 119{
120 [super onExit];
121
114 [touchDelegatingView removeFromSuperview]; 122 [touchDelegatingView removeFromSuperview];
115 [scrollView removeFromSuperview]; 123 [scrollView removeFromSuperview];
116 [pageControl removeFromSuperview]; 124 [pageControl removeFromSuperview];