diff options
Diffstat (limited to 'Classes')
| -rw-r--r-- | Classes/GameModeSelectionLayer.m | 20 |
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]; |
