From 02d9a87417837ffda602b2d06c2c6897d15a1202 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Tue, 23 Aug 2011 09:24:14 -0400 Subject: Added a UIPageControl to the level selection screen The page control updates when you swipe through the levels, but tapping it does nothing. I initially attempted to implement scrolling by tapping on the page control, but for some reason, it worked perfectly in the simulator and only randomly on the iPhone. Very weird. Refs #207 --- Classes/GameModeSelectionLayer.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Classes/GameModeSelectionLayer.m') diff --git a/Classes/GameModeSelectionLayer.m b/Classes/GameModeSelectionLayer.m index 9875d41..ad6a455 100644 --- a/Classes/GameModeSelectionLayer.m +++ b/Classes/GameModeSelectionLayer.m @@ -86,9 +86,15 @@ [panels addChild:menu]; [self addChild:panels]; + pageControl = [[UIPageControl alloc] init]; + 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]; + 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]; @@ -107,6 +113,7 @@ { [touchDelegatingView removeFromSuperview]; [scrollView removeFromSuperview]; + [pageControl removeFromSuperview]; } - (void)mainmenu -- cgit 1.4.1