summary refs log tree commit diff stats
path: root/Classes
diff options
context:
space:
mode:
Diffstat (limited to 'Classes')
-rwxr-xr-xClasses/CocosOverlayScrollView.h3
-rwxr-xr-xClasses/CocosOverlayScrollView.m9
-rw-r--r--Classes/GameModeSelectionLayer.h1
-rw-r--r--Classes/GameModeSelectionLayer.m9
4 files changed, 19 insertions, 3 deletions
diff --git a/Classes/CocosOverlayScrollView.h b/Classes/CocosOverlayScrollView.h index 29de1c7..ad8e83f 100755 --- a/Classes/CocosOverlayScrollView.h +++ b/Classes/CocosOverlayScrollView.h
@@ -12,7 +12,8 @@
12@interface CocosOverlayScrollView : UIScrollView <UIScrollViewDelegate> 12@interface CocosOverlayScrollView : UIScrollView <UIScrollViewDelegate>
13{ 13{
14 CCNode* targetLayer; 14 CCNode* targetLayer;
15 UIPageControl* pageControl;
15} 16}
16@property(nonatomic, retain) CCNode* targetLayer; 17@property(nonatomic, retain) CCNode* targetLayer;
17-(id) initWithFrame: (CGRect) frameRect numPages: (int) numPages width: (float) width layer: (CCNode*) layer; 18-(id) initWithFrame: (CGRect) frameRect numPages: (int) numPages width: (float) width layer: (CCNode*) layer pageControl:(UIPageControl*)pageControl;
18@end 19@end
diff --git a/Classes/CocosOverlayScrollView.m b/Classes/CocosOverlayScrollView.m index dcf5571..dee9dfe 100755 --- a/Classes/CocosOverlayScrollView.m +++ b/Classes/CocosOverlayScrollView.m
@@ -12,7 +12,7 @@
12@synthesize targetLayer; 12@synthesize targetLayer;
13 13
14// Configure your favorite UIScrollView options here 14// Configure your favorite UIScrollView options here
15-(id) initWithFrame: (CGRect) frameRect numPages: (int) numPages width: (float) width layer: (CCNode*) layer { 15-(id) initWithFrame: (CGRect) frameRect numPages: (int) numPages width: (float) width layer: (CCNode*) layer pageControl:(UIPageControl *)m_pageControl{
16 if ((self = [super initWithFrame: frameRect])){ 16 if ((self = [super initWithFrame: frameRect])){
17 self.contentSize = CGSizeMake(width*numPages, 320); 17 self.contentSize = CGSizeMake(width*numPages, 320);
18 self.bounces = YES; 18 self.bounces = YES;
@@ -26,6 +26,7 @@
26 [self setScrollEnabled:TRUE]; 26 [self setScrollEnabled:TRUE];
27 self.targetLayer = layer; 27 self.targetLayer = layer;
28 // self.canCancelContentTouches = YES; 28 // self.canCancelContentTouches = YES;
29 pageControl = m_pageControl;
29 } 30 }
30 return self; 31 return self;
31} 32}
@@ -96,4 +97,10 @@
96 self.targetLayer = nil; 97 self.targetLayer = nil;
97 [super dealloc]; 98 [super dealloc];
98} 99}
100
101- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
102{
103 [pageControl setCurrentPage:(NSUInteger)([scrollView contentOffset].x / [scrollView frame].size.width)];
104}
105
99@end \ No newline at end of file 106@end \ No newline at end of file
diff --git a/Classes/GameModeSelectionLayer.h b/Classes/GameModeSelectionLayer.h index 451a5f8..478a173 100644 --- a/Classes/GameModeSelectionLayer.h +++ b/Classes/GameModeSelectionLayer.h
@@ -15,6 +15,7 @@
15 NSMutableArray* gameModes; 15 NSMutableArray* gameModes;
16 TouchDelegatingView* touchDelegatingView; 16 TouchDelegatingView* touchDelegatingView;
17 CocosOverlayScrollView* scrollView; 17 CocosOverlayScrollView* scrollView;
18 UIPageControl* pageControl;
18} 19}
19 20
20+ (CCScene*)scene; 21+ (CCScene*)scene;
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 @@
86 [panels addChild:menu]; 86 [panels addChild:menu];
87 [self addChild:panels]; 87 [self addChild:panels];
88 88
89 pageControl = [[UIPageControl alloc] init];
90 pageControl.numberOfPages = numberOfPanels;
91 pageControl.currentPage = currentWorldOffset;
92 pageControl.frame = CGRectMake(0, 250, 480, 20);
93 [[[CCDirector sharedDirector] openGLView] addSubview:pageControl];
94
89 menu.position = ccpAdd(menu.position, ccp(totalWidth/2 - totalPanelWidth/2, 320)); 95 menu.position = ccpAdd(menu.position, ccp(totalWidth/2 - totalPanelWidth/2, 320));
90 touchDelegatingView = [[TouchDelegatingView alloc] initWithFrame:CGRectMake(0, 0, 480, 320)]; 96 touchDelegatingView = [[TouchDelegatingView alloc] initWithFrame:CGRectMake(0, 0, 480, 320)];
91 scrollView = [[CocosOverlayScrollView alloc] initWithFrame:CGRectMake(0, 0, totalPanelWidth, 320) numPages:numberOfPanels width:totalPanelWidth layer:panels]; 97 scrollView = [[CocosOverlayScrollView alloc] initWithFrame:CGRectMake(0, 0, totalPanelWidth, 320) numPages:numberOfPanels width:totalPanelWidth layer:panels pageControl:pageControl];
92 touchDelegatingView.scrollView = scrollView; 98 touchDelegatingView.scrollView = scrollView;
93 [scrollView setContentOffset:CGPointMake(currentWorldOffset*totalPanelWidth+1,0) animated:NO]; 99 [scrollView setContentOffset:CGPointMake(currentWorldOffset*totalPanelWidth+1,0) animated:NO];
94 [[[CCDirector sharedDirector] openGLView] addSubview:touchDelegatingView]; 100 [[[CCDirector sharedDirector] openGLView] addSubview:touchDelegatingView];
@@ -107,6 +113,7 @@
107{ 113{
108 [touchDelegatingView removeFromSuperview]; 114 [touchDelegatingView removeFromSuperview];
109 [scrollView removeFromSuperview]; 115 [scrollView removeFromSuperview];
116 [pageControl removeFromSuperview];
110} 117}
111 118
112- (void)mainmenu 119- (void)mainmenu