diff options
author | Starla Insigna <starla4444@gmail.com> | 2011-08-23 07:52:24 -0400 |
---|---|---|
committer | Starla Insigna <starla4444@gmail.com> | 2011-08-23 07:52:24 -0400 |
commit | c9337218ef1660360097928c753bde1c79775618 (patch) | |
tree | 3cd6f9926cbe092c98776673800b830eef27ca01 /Classes | |
parent | 2ac50443ddbf69b7594808ba4e6de49eecbc0b84 (diff) | |
download | cartcollect-c9337218ef1660360097928c753bde1c79775618.tar.gz cartcollect-c9337218ef1660360097928c753bde1c79775618.tar.bz2 cartcollect-c9337218ef1660360097928c753bde1c79775618.zip |
Added scrolling to level selection screen
Using http://www.xcombinator.com/2010/09/08/a-paging-uiscrollview-in-cocos2d-with-previews/ as a base, I was able to implement a paging scroller for the level selection screen so players can swipe through available levels and choose one to play. At this point, the level selection screen is practically done--the only other thing I want to add is a UIPageControl to interact with the scrolling and give the player an indication of how many levels there are. Refs #207
Diffstat (limited to 'Classes')
-rwxr-xr-x | Classes/CocosOverlayScrollView.h | 18 | ||||
-rwxr-xr-x | Classes/CocosOverlayScrollView.m | 99 | ||||
-rw-r--r-- | Classes/GameModeSelection.h | 8 | ||||
-rw-r--r-- | Classes/GameModeSelection.m | 35 | ||||
-rw-r--r-- | Classes/GameModeSelectionDelegate.h | 17 | ||||
-rw-r--r-- | Classes/GameModeSelectionLayer.h | 9 | ||||
-rw-r--r-- | Classes/GameModeSelectionLayer.m | 66 | ||||
-rwxr-xr-x | Classes/NMPanelMenu.h | 14 | ||||
-rwxr-xr-x | Classes/NMPanelMenu.m | 37 | ||||
-rwxr-xr-x | Classes/TouchDelegatingView.h | 18 | ||||
-rwxr-xr-x | Classes/TouchDelegatingView.m | 26 |
11 files changed, 326 insertions, 21 deletions
diff --git a/Classes/CocosOverlayScrollView.h b/Classes/CocosOverlayScrollView.h new file mode 100755 index 0000000..29de1c7 --- /dev/null +++ b/Classes/CocosOverlayScrollView.h | |||
@@ -0,0 +1,18 @@ | |||
1 | // | ||
2 | // CocosOverlayScrollView.h | ||
3 | // shapes | ||
4 | // | ||
5 | // Created by Nate Murray on 8/23/10. | ||
6 | // Copyright 2010 LittleHiccup. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import <Foundation/Foundation.h> | ||
10 | #import "cocos2d.h" | ||
11 | |||
12 | @interface CocosOverlayScrollView : UIScrollView <UIScrollViewDelegate> | ||
13 | { | ||
14 | CCNode* targetLayer; | ||
15 | } | ||
16 | @property(nonatomic, retain) CCNode* targetLayer; | ||
17 | -(id) initWithFrame: (CGRect) frameRect numPages: (int) numPages width: (float) width layer: (CCNode*) layer; | ||
18 | @end | ||
diff --git a/Classes/CocosOverlayScrollView.m b/Classes/CocosOverlayScrollView.m new file mode 100755 index 0000000..dcf5571 --- /dev/null +++ b/Classes/CocosOverlayScrollView.m | |||
@@ -0,0 +1,99 @@ | |||
1 | // | ||
2 | // CocosOverlayScrollView.m | ||
3 | // shapes | ||
4 | // | ||
5 | // Created by Nate Murray on 8/23/10. | ||
6 | // Copyright 2010 LittleHiccup. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import "CocosOverlayScrollView.h" | ||
10 | |||
11 | @implementation CocosOverlayScrollView | ||
12 | @synthesize targetLayer; | ||
13 | |||
14 | // Configure your favorite UIScrollView options here | ||
15 | -(id) initWithFrame: (CGRect) frameRect numPages: (int) numPages width: (float) width layer: (CCNode*) layer { | ||
16 | if ((self = [super initWithFrame: frameRect])){ | ||
17 | self.contentSize = CGSizeMake(width*numPages, 320); | ||
18 | self.bounces = YES; | ||
19 | self.delaysContentTouches = NO; | ||
20 | self.delegate = self; | ||
21 | self.pagingEnabled = YES; | ||
22 | self.scrollsToTop = NO; | ||
23 | self.showsVerticalScrollIndicator = NO; | ||
24 | self.showsHorizontalScrollIndicator = NO; | ||
25 | [self setUserInteractionEnabled:TRUE]; | ||
26 | [self setScrollEnabled:TRUE]; | ||
27 | self.targetLayer = layer; | ||
28 | // self.canCancelContentTouches = YES; | ||
29 | } | ||
30 | return self; | ||
31 | } | ||
32 | |||
33 | -(void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event | ||
34 | { | ||
35 | if (!self.dragging) | ||
36 | { | ||
37 | // UITouch* touch = [[touches allObjects] objectAtIndex:0]; | ||
38 | // CGPoint location = [touch locationInView: [[touch view] superview]]; | ||
39 | // CCLOG(@"touch at l.x:%f l.y:%f", location.x, location.y); | ||
40 | |||
41 | [self.nextResponder touchesBegan: touches withEvent:event]; | ||
42 | [[[CCDirector sharedDirector] openGLView] touchesBegan:touches withEvent:event]; | ||
43 | } | ||
44 | |||
45 | [super touchesBegan: touches withEvent: event]; | ||
46 | } | ||
47 | |||
48 | -(void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event | ||
49 | { | ||
50 | if (!self.dragging) | ||
51 | { | ||
52 | [self.nextResponder touchesEnded: touches withEvent:event]; | ||
53 | [[[CCDirector sharedDirector] openGLView] touchesEnded:touches withEvent:event]; | ||
54 | } | ||
55 | |||
56 | [super touchesEnded: touches withEvent: event]; | ||
57 | } | ||
58 | |||
59 | -(void) touchesCancelled: (NSSet *) touches withEvent: (UIEvent *) event | ||
60 | { | ||
61 | // if (!self.dragging) | ||
62 | // { | ||
63 | // CCLOG(@"CocosOverlayScrollView touchesEnded not dragging"); | ||
64 | [self.nextResponder touchesCancelled: touches withEvent:event]; | ||
65 | [[[CCDirector sharedDirector] openGLView] touchesCancelled:touches withEvent:event]; | ||
66 | // } | ||
67 | [super touchesCancelled: touches withEvent: event]; | ||
68 | } | ||
69 | |||
70 | |||
71 | - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView | ||
72 | { | ||
73 | // TODO - Custom code for handling deceleration of the scroll view | ||
74 | } | ||
75 | |||
76 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView | ||
77 | { | ||
78 | CGPoint dragPt = [scrollView contentOffset]; | ||
79 | dragPt = [[CCDirector sharedDirector] convertToGL:dragPt]; | ||
80 | |||
81 | dragPt.y = dragPt.y * -1; | ||
82 | dragPt.x = dragPt.x * -1; | ||
83 | |||
84 | CGPoint newLayerPosition = CGPointMake(dragPt.x, dragPt.y); | ||
85 | |||
86 | [targetLayer setPosition:newLayerPosition]; | ||
87 | } | ||
88 | |||
89 | - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView | ||
90 | { | ||
91 | // CGPoint dragPt = [scrollView contentOffset]; | ||
92 | // etc. | ||
93 | } | ||
94 | |||
95 | -(void) dealloc { | ||
96 | self.targetLayer = nil; | ||
97 | [super dealloc]; | ||
98 | } | ||
99 | @end \ No newline at end of file | ||
diff --git a/Classes/GameModeSelection.h b/Classes/GameModeSelection.h index f6aaeff..f69ea37 100644 --- a/Classes/GameModeSelection.h +++ b/Classes/GameModeSelection.h | |||
@@ -7,17 +7,23 @@ | |||
7 | // | 7 | // |
8 | 8 | ||
9 | #import "cocos2d.h" | 9 | #import "cocos2d.h" |
10 | #import "GameModeSelectionDelegate.h" | ||
10 | 11 | ||
11 | @interface GameModeSelection : CCNode { | 12 | @interface GameModeSelection : CCMenuItem { |
12 | NSString* name; | 13 | NSString* name; |
13 | NSString* location; | 14 | NSString* location; |
14 | BOOL unlocked; | 15 | BOOL unlocked; |
15 | NSString* unlockCondition; | 16 | NSString* unlockCondition; |
17 | id<GameModeSelectionDelegate> delegate; | ||
16 | } | 18 | } |
17 | 19 | ||
18 | @property (readonly) NSString* name; | 20 | @property (readonly) NSString* name; |
19 | @property (readonly) NSString* location; | 21 | @property (readonly) NSString* location; |
20 | @property (readonly) BOOL unlocked; | 22 | @property (readonly) BOOL unlocked; |
23 | @property (nonatomic,retain) id<GameModeSelectionDelegate> delegate; | ||
24 | + (id)selectionWithName:(NSString*)name location:(NSString*)location filename:(NSString*)filename unlocked:(BOOL)unlocked; | ||
25 | + (id)selectionWithName:(NSString *)name location:(NSString *)location filename:(NSString *)filename highscore:(int)highscore; | ||
26 | + (id)selectionWithName:(NSString *)name location:(NSString *)location filename:(NSString *)filename unlockCondition:(NSString*)unlockCondition; | ||
21 | - (id)initWithName:(NSString*)name location:(NSString*)location filename:(NSString*)filename unlocked:(BOOL)unlocked; | 27 | - (id)initWithName:(NSString*)name location:(NSString*)location filename:(NSString*)filename unlocked:(BOOL)unlocked; |
22 | - (id)initWithName:(NSString *)name location:(NSString *)location filename:(NSString *)filename highscore:(int)highscore; | 28 | - (id)initWithName:(NSString *)name location:(NSString *)location filename:(NSString *)filename highscore:(int)highscore; |
23 | - (id)initWithName:(NSString *)name location:(NSString *)location filename:(NSString *)filename unlockCondition:(NSString*)unlockCondition; | 29 | - (id)initWithName:(NSString *)name location:(NSString *)location filename:(NSString *)filename unlockCondition:(NSString*)unlockCondition; |
diff --git a/Classes/GameModeSelection.m b/Classes/GameModeSelection.m index fc6797a..582c9dd 100644 --- a/Classes/GameModeSelection.m +++ b/Classes/GameModeSelection.m | |||
@@ -7,17 +7,31 @@ | |||
7 | // | 7 | // |
8 | 8 | ||
9 | #import "GameModeSelection.h" | 9 | #import "GameModeSelection.h" |
10 | #import "TutorialMode.h" | ||
11 | #import "ClassicGameMode.h" | ||
12 | #import "UIImage+ColorMasking.h" | 10 | #import "UIImage+ColorMasking.h" |
11 | #import "NMPanelMenu.h" | ||
13 | 12 | ||
14 | @implementation GameModeSelection | 13 | @implementation GameModeSelection |
15 | 14 | ||
16 | @synthesize name, location, unlocked; | 15 | @synthesize name, location, unlocked, delegate; |
16 | |||
17 | + (id)selectionWithName:(NSString*)name location:(NSString*)location filename:(NSString*)filename unlocked:(BOOL)unlocked | ||
18 | { | ||
19 | return [[[GameModeSelection alloc] initWithName:name location:location filename:filename unlocked:unlocked] autorelease]; | ||
20 | } | ||
21 | |||
22 | + (id)selectionWithName:(NSString *)name location:(NSString *)location filename:(NSString *)filename highscore:(int)highscore | ||
23 | { | ||
24 | return [[[GameModeSelection alloc] initWithName:name location:location filename:filename highscore:highscore] autorelease]; | ||
25 | } | ||
26 | |||
27 | + (id)selectionWithName:(NSString *)name location:(NSString *)location filename:(NSString *)filename unlockCondition:(NSString*)unlockCondition | ||
28 | { | ||
29 | return [[[GameModeSelection alloc] initWithName:name location:location filename:filename unlockCondition:unlockCondition] autorelease]; | ||
30 | } | ||
17 | 31 | ||
18 | - (id)initWithName:(NSString*)m_name location:(NSString*)m_location filename:(NSString*)filename unlocked:(BOOL)m_unlocked; | 32 | - (id)initWithName:(NSString*)m_name location:(NSString*)m_location filename:(NSString*)filename unlocked:(BOOL)m_unlocked; |
19 | { | 33 | { |
20 | self = [super init]; | 34 | self = [super initWithTarget:nil selector:nil]; |
21 | 35 | ||
22 | if (nil != self) | 36 | if (nil != self) |
23 | { | 37 | { |
@@ -27,6 +41,8 @@ | |||
27 | location = m_location; | 41 | location = m_location; |
28 | unlocked = m_unlocked; | 42 | unlocked = m_unlocked; |
29 | 43 | ||
44 | contentSize_ = CGSizeMake(128, 320); | ||
45 | |||
30 | NSString* filenameMod; | 46 | NSString* filenameMod; |
31 | 47 | ||
32 | if (unlocked) | 48 | if (unlocked) |
@@ -124,7 +140,7 @@ | |||
124 | CCSprite* selectedButton = [CCSprite spriteWithCGImage:selectedButtonRef key:[NSString stringWithFormat:@"gms-%@-selected", filenameMod]]; | 140 | CCSprite* selectedButton = [CCSprite spriteWithCGImage:selectedButtonRef key:[NSString stringWithFormat:@"gms-%@-selected", filenameMod]]; |
125 | 141 | ||
126 | CCMenuItemSprite* pictureMenuItem = [CCMenuItemSprite itemFromNormalSprite:picture selectedSprite:selectedButton target:self selector:@selector(buttonTapped)]; | 142 | CCMenuItemSprite* pictureMenuItem = [CCMenuItemSprite itemFromNormalSprite:picture selectedSprite:selectedButton target:self selector:@selector(buttonTapped)]; |
127 | CCMenu* theMenu = [CCMenu menuWithItems:pictureMenuItem, nil]; | 143 | NMPanelMenu* theMenu = [NMPanelMenu menuWithItems:pictureMenuItem, nil]; |
128 | theMenu.position = ccp(-5, 0); | 144 | theMenu.position = ccp(-5, 0); |
129 | [self addChild:theMenu]; | 145 | [self addChild:theMenu]; |
130 | 146 | ||
@@ -196,12 +212,11 @@ | |||
196 | { | 212 | { |
197 | if (unlocked) | 213 | if (unlocked) |
198 | { | 214 | { |
199 | if ([name isEqual:@"Tutorial"]) | 215 | if (delegate != nil) |
200 | { | ||
201 | [[CCDirector sharedDirector] replaceScene:[TutorialMode scene]]; | ||
202 | } else if ([name isEqual:@"Collect"]) | ||
203 | { | 216 | { |
204 | [[CCDirector sharedDirector] replaceScene:[ClassicGameMode scene]]; | 217 | [delegate didSelectGameMode:self]; |
218 | } else { | ||
219 | NSLog(@"I don't have a GameModeSelectionDelegate to call for some reason..."); | ||
205 | } | 220 | } |
206 | } else { | 221 | } else { |
207 | UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"To unlock this game mode:" message:unlockCondition delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; | 222 | UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"To unlock this game mode:" message:unlockCondition delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; |
diff --git a/Classes/GameModeSelectionDelegate.h b/Classes/GameModeSelectionDelegate.h new file mode 100644 index 0000000..854a980 --- /dev/null +++ b/Classes/GameModeSelectionDelegate.h | |||
@@ -0,0 +1,17 @@ | |||
1 | // | ||
2 | // GameModeSelectionDelegate.h | ||
3 | // Cartographic | ||
4 | // | ||
5 | // Created by Starla Insigna on 8/23/11. | ||
6 | // Copyright 2011 Four Island. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import <Foundation/Foundation.h> | ||
10 | |||
11 | @class GameModeSelection; | ||
12 | |||
13 | @protocol GameModeSelectionDelegate <NSObject> | ||
14 | |||
15 | - (void)didSelectGameMode:(GameModeSelection*)gameMode; | ||
16 | |||
17 | @end | ||
diff --git a/Classes/GameModeSelectionLayer.h b/Classes/GameModeSelectionLayer.h index 2f57bfb..451a5f8 100644 --- a/Classes/GameModeSelectionLayer.h +++ b/Classes/GameModeSelectionLayer.h | |||
@@ -7,8 +7,15 @@ | |||
7 | // | 7 | // |
8 | 8 | ||
9 | #import "cocos2d.h" | 9 | #import "cocos2d.h" |
10 | #import "TouchDelegatingView.h" | ||
11 | #import "CocosOverlayScrollView.h" | ||
12 | #import "GameModeSelectionDelegate.h" | ||
10 | 13 | ||
11 | @interface GameModeSelectionLayer : CCLayer | 14 | @interface GameModeSelectionLayer : CCLayer <GameModeSelectionDelegate> { |
15 | NSMutableArray* gameModes; | ||
16 | TouchDelegatingView* touchDelegatingView; | ||
17 | CocosOverlayScrollView* scrollView; | ||
18 | } | ||
12 | 19 | ||
13 | + (CCScene*)scene; | 20 | + (CCScene*)scene; |
14 | - (id)init; | 21 | - (id)init; |
diff --git a/Classes/GameModeSelectionLayer.m b/Classes/GameModeSelectionLayer.m index a90606e..9875d41 100644 --- a/Classes/GameModeSelectionLayer.m +++ b/Classes/GameModeSelectionLayer.m | |||
@@ -11,6 +11,8 @@ | |||
11 | #import <sqlite3.h> | 11 | #import <sqlite3.h> |
12 | #import "Cart_CollectAppDelegate.h" | 12 | #import "Cart_CollectAppDelegate.h" |
13 | #import "MainMenuLayer.h" | 13 | #import "MainMenuLayer.h" |
14 | #import "TutorialMode.h" | ||
15 | #import "ClassicGameMode.h" | ||
14 | 16 | ||
15 | @implementation GameModeSelectionLayer | 17 | @implementation GameModeSelectionLayer |
16 | 18 | ||
@@ -36,12 +38,14 @@ | |||
36 | 38 | ||
37 | if (nil != self) | 39 | if (nil != self) |
38 | { | 40 | { |
39 | // Initialization code here. | 41 | gameModes = [[NSMutableArray alloc] init]; |
40 | GameModeSelection* tutorialSelection = [[[GameModeSelection alloc] initWithName:@"Tutorial" location:@"Florence" filename:@"florence" unlocked:YES] autorelease]; | 42 | CCMenu* menu = [CCMenu menuWithItems:nil]; |
41 | tutorialSelection.position = ccp(160-32,160); | ||
42 | [self addChild:tutorialSelection]; | ||
43 | |||
44 | NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | 43 | NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; |
44 | float onePanelWide = 128; | ||
45 | |||
46 | GameModeSelection* tutorialSelection = [GameModeSelection selectionWithName:@"Tutorial" location:@"Florence" filename:@"florence" unlocked:YES]; | ||
47 | [gameModes addObject:tutorialSelection]; | ||
48 | |||
45 | GameModeSelection* collectSelection; | 49 | GameModeSelection* collectSelection; |
46 | 50 | ||
47 | if ([defaults boolForKey:@"hasDoneTutorial"]) | 51 | if ([defaults boolForKey:@"hasDoneTutorial"]) |
@@ -58,13 +62,37 @@ | |||
58 | } | 62 | } |
59 | } | 63 | } |
60 | 64 | ||
61 | collectSelection = [[[GameModeSelection alloc] initWithName:@"Collect" location:@"Paris" filename:@"paris" highscore:score] autorelease]; | 65 | collectSelection = [GameModeSelection selectionWithName:@"Collect" location:@"Paris" filename:@"paris" highscore:score]; |
62 | } else { | 66 | } else { |
63 | collectSelection = [[[GameModeSelection alloc] initWithName:@"Collect" location:@"Paris" filename:@"paris" unlockCondition:@"Beat the tutorial!"] autorelease]; | 67 | collectSelection = [GameModeSelection selectionWithName:@"Collect" location:@"Paris" filename:@"paris" unlockCondition:@"Beat the tutorial!"]; |
68 | } | ||
69 | |||
70 | [gameModes addObject:collectSelection]; | ||
71 | |||
72 | float padding = 15; | ||
73 | float totalPanelWidth = onePanelWide + padding*2; | ||
74 | float numberOfPanels = [gameModes count]; | ||
75 | float totalWidth = numberOfPanels * totalPanelWidth; | ||
76 | int currentWorldOffset = [defaults integerForKey:@"lastSelectedMode"]; | ||
77 | CCLayer* panels = [CCLayer node]; | ||
78 | |||
79 | for (GameModeSelection* gameMode in gameModes) | ||
80 | { | ||
81 | [gameMode setDelegate:self]; | ||
82 | [menu addChild:gameMode]; | ||
64 | } | 83 | } |
65 | 84 | ||
66 | collectSelection.position = ccp(320+32,160); | 85 | [menu alignItemsHorizontallyWithPadding:padding*2]; |
67 | [self addChild:collectSelection]; | 86 | [panels addChild:menu]; |
87 | [self addChild:panels]; | ||
88 | |||
89 | menu.position = ccpAdd(menu.position, ccp(totalWidth/2 - totalPanelWidth/2, 320)); | ||
90 | 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]; | ||
92 | touchDelegatingView.scrollView = scrollView; | ||
93 | [scrollView setContentOffset:CGPointMake(currentWorldOffset*totalPanelWidth+1,0) animated:NO]; | ||
94 | [[[CCDirector sharedDirector] openGLView] addSubview:touchDelegatingView]; | ||
95 | [[[CCDirector sharedDirector] openGLView] addSubview:scrollView]; | ||
68 | 96 | ||
69 | CCMenuItemImage* newgameMenuItem = [CCMenuItemImage itemFromNormalImage:@"back.png" selectedImage:@"back2.png" target:self selector:@selector(mainmenu)]; | 97 | CCMenuItemImage* newgameMenuItem = [CCMenuItemImage itemFromNormalImage:@"back.png" selectedImage:@"back2.png" target:self selector:@selector(mainmenu)]; |
70 | CCMenu* myMenu = [CCMenu menuWithItems:newgameMenuItem, nil]; | 98 | CCMenu* myMenu = [CCMenu menuWithItems:newgameMenuItem, nil]; |
@@ -75,9 +103,29 @@ | |||
75 | return self; | 103 | return self; |
76 | } | 104 | } |
77 | 105 | ||
106 | - (void)onExit | ||
107 | { | ||
108 | [touchDelegatingView removeFromSuperview]; | ||
109 | [scrollView removeFromSuperview]; | ||
110 | } | ||
111 | |||
78 | - (void)mainmenu | 112 | - (void)mainmenu |
79 | { | 113 | { |
80 | [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]]; | 114 | [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]]; |
81 | } | 115 | } |
82 | 116 | ||
117 | - (void)didSelectGameMode:(GameModeSelection *)gameMode | ||
118 | { | ||
119 | NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | ||
120 | [defaults setInteger:[gameModes indexOfObject:gameMode] forKey:@"lastSelectedMode"]; | ||
121 | |||
122 | if ([gameMode.name isEqual:@"Tutorial"]) | ||
123 | { | ||
124 | [[CCDirector sharedDirector] replaceScene:[TutorialMode scene]]; | ||
125 | } else if ([gameMode.name isEqual:@"Collect"]) | ||
126 | { | ||
127 | [[CCDirector sharedDirector] replaceScene:[ClassicGameMode scene]]; | ||
128 | } | ||
129 | } | ||
130 | |||
83 | @end | 131 | @end |
diff --git a/Classes/NMPanelMenu.h b/Classes/NMPanelMenu.h new file mode 100755 index 0000000..3487849 --- /dev/null +++ b/Classes/NMPanelMenu.h | |||
@@ -0,0 +1,14 @@ | |||
1 | /* | ||
2 | * NMPanelMenu.h | ||
3 | * shapes | ||
4 | * | ||
5 | * Created by Nate Murray on 7/29/10. | ||
6 | * Copyright 2010 YetiApps. All rights reserved. | ||
7 | * | ||
8 | */ | ||
9 | |||
10 | #import "cocos2d.h" | ||
11 | @interface NMPanelMenu : CCMenu { | ||
12 | } | ||
13 | -(CCMenuItem *) itemForTouch: (UITouch *) touch; | ||
14 | @end | ||
diff --git a/Classes/NMPanelMenu.m b/Classes/NMPanelMenu.m new file mode 100755 index 0000000..ee24279 --- /dev/null +++ b/Classes/NMPanelMenu.m | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * NMPanelMenu.m | ||
3 | * shapes | ||
4 | * | ||
5 | * Created by Nate Murray on 7/29/10. | ||
6 | * Copyright 2010 YetiApps. All rights reserved. | ||
7 | * | ||
8 | */ | ||
9 | |||
10 | #import "NMPanelMenu.h" | ||
11 | |||
12 | @implementation NMPanelMenu | ||
13 | |||
14 | -(CCMenuItem *) itemForTouch: (UITouch *) touch | ||
15 | { | ||
16 | CGPoint touchLocation = [touch locationInView: [[touch view] superview]]; | ||
17 | touchLocation = [[CCDirector sharedDirector] convertToGL: touchLocation]; | ||
18 | |||
19 | CCMenuItem* item; | ||
20 | CCARRAY_FOREACH(children_, item){ | ||
21 | // ignore invisible and disabled items: issue #779, #866 | ||
22 | if ( [item visible] && [item isEnabled] ) { | ||
23 | |||
24 | CGPoint local = [item convertToNodeSpace:touchLocation]; | ||
25 | |||
26 | CGRect r = [item rect]; | ||
27 | r.origin = CGPointZero; | ||
28 | |||
29 | if( CGRectContainsPoint( r, local ) ) { | ||
30 | return item; | ||
31 | } | ||
32 | } | ||
33 | } | ||
34 | return nil; | ||
35 | } | ||
36 | |||
37 | @end | ||
diff --git a/Classes/TouchDelegatingView.h b/Classes/TouchDelegatingView.h new file mode 100755 index 0000000..5ed6884 --- /dev/null +++ b/Classes/TouchDelegatingView.h | |||
@@ -0,0 +1,18 @@ | |||
1 | // | ||
2 | // TouchDelegatingView.h | ||
3 | // shapes | ||
4 | // | ||
5 | // Created by Nate Murray on 8/23/10. | ||
6 | // Copyright 2010 LittleHiccup. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import <Foundation/Foundation.h> | ||
10 | #import "CocosOverLayScrollView.h" | ||
11 | |||
12 | @interface TouchDelegatingView : UIView { | ||
13 | // UIPageControl* pageControl; | ||
14 | CocosOverlayScrollView* scrollView; | ||
15 | } | ||
16 | @property(nonatomic, retain) CocosOverlayScrollView* scrollView; | ||
17 | |||
18 | @end | ||
diff --git a/Classes/TouchDelegatingView.m b/Classes/TouchDelegatingView.m new file mode 100755 index 0000000..83bda73 --- /dev/null +++ b/Classes/TouchDelegatingView.m | |||
@@ -0,0 +1,26 @@ | |||
1 | // | ||
2 | // TouchDelegatingView.m | ||
3 | // Jacob's Shapes | ||
4 | // | ||
5 | // Created by Nate Murray on 8/23/10. | ||
6 | // Copyright 2010 LittleHiccup. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import "TouchDelegatingView.h" | ||
10 | |||
11 | @implementation TouchDelegatingView | ||
12 | @synthesize scrollView; | ||
13 | |||
14 | - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { | ||
15 | if ([self pointInside:point withEvent:event]) { | ||
16 | return self.scrollView; | ||
17 | } | ||
18 | return nil; | ||
19 | } | ||
20 | |||
21 | -(void) dealloc { | ||
22 | self.scrollView = nil; | ||
23 | [super dealloc]; | ||
24 | } | ||
25 | |||
26 | @end | ||