summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xCartographic.xcodeproj/project.pbxproj40
-rwxr-xr-xClasses/CocosOverlayScrollView.h18
-rwxr-xr-xClasses/CocosOverlayScrollView.m99
-rw-r--r--Classes/GameModeSelection.h8
-rw-r--r--Classes/GameModeSelection.m35
-rw-r--r--Classes/GameModeSelectionDelegate.h17
-rw-r--r--Classes/GameModeSelectionLayer.h9
-rw-r--r--Classes/GameModeSelectionLayer.m66
-rwxr-xr-xClasses/NMPanelMenu.h14
-rwxr-xr-xClasses/NMPanelMenu.m37
-rwxr-xr-xClasses/TouchDelegatingView.h18
-rwxr-xr-xClasses/TouchDelegatingView.m26
12 files changed, 360 insertions, 27 deletions
diff --git a/Cartographic.xcodeproj/project.pbxproj b/Cartographic.xcodeproj/project.pbxproj index cda609e..59cf7cd 100755 --- a/Cartographic.xcodeproj/project.pbxproj +++ b/Cartographic.xcodeproj/project.pbxproj
@@ -102,6 +102,9 @@
102 6C0C141113F2099B003A31B2 /* Cart.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C0C141013F2099B003A31B2 /* Cart.m */; }; 102 6C0C141113F2099B003A31B2 /* Cart.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C0C141013F2099B003A31B2 /* Cart.m */; };
103 6C0C141413F20E98003A31B2 /* GameMode.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C0C141313F20E98003A31B2 /* GameMode.m */; }; 103 6C0C141413F20E98003A31B2 /* GameMode.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C0C141313F20E98003A31B2 /* GameMode.m */; };
104 6C18C3CA1402AD9C0005AA4C /* UIImage+ColorMasking.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C18C3C91402AD9C0005AA4C /* UIImage+ColorMasking.m */; }; 104 6C18C3CA1402AD9C0005AA4C /* UIImage+ColorMasking.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C18C3C91402AD9C0005AA4C /* UIImage+ColorMasking.m */; };
105 6C18C3D214033DC50005AA4C /* CocosOverlayScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C18C3CD14033DC10005AA4C /* CocosOverlayScrollView.m */; };
106 6C18C3D314033DC60005AA4C /* NMPanelMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C18C3CF14033DC30005AA4C /* NMPanelMenu.m */; };
107 6C18C3D414033DC60005AA4C /* TouchDelegatingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C18C3D114033DC40005AA4C /* TouchDelegatingView.m */; };
105 6C29041013EAEB590032DA0F /* TutorialBubble.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C29040F13EAEB590032DA0F /* TutorialBubble.m */; }; 108 6C29041013EAEB590032DA0F /* TutorialBubble.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C29040F13EAEB590032DA0F /* TutorialBubble.m */; };
106 6C29041213EAEC8A0032DA0F /* framestuff.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C29041113EAEC8A0032DA0F /* framestuff.png */; }; 109 6C29041213EAEC8A0032DA0F /* framestuff.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C29041113EAEC8A0032DA0F /* framestuff.png */; };
107 6C39CFE013FC2708002B21AF /* tutorial.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C39CFDF13FC2708002B21AF /* tutorial.png */; }; 110 6C39CFE013FC2708002B21AF /* tutorial.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C39CFDF13FC2708002B21AF /* tutorial.png */; };
@@ -414,6 +417,12 @@
414 6C0C141313F20E98003A31B2 /* GameMode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameMode.m; sourceTree = "<group>"; }; 417 6C0C141313F20E98003A31B2 /* GameMode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameMode.m; sourceTree = "<group>"; };
415 6C18C3C81402AD9C0005AA4C /* UIImage+ColorMasking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+ColorMasking.h"; sourceTree = "<group>"; }; 418 6C18C3C81402AD9C0005AA4C /* UIImage+ColorMasking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+ColorMasking.h"; sourceTree = "<group>"; };
416 6C18C3C91402AD9C0005AA4C /* UIImage+ColorMasking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+ColorMasking.m"; sourceTree = "<group>"; }; 419 6C18C3C91402AD9C0005AA4C /* UIImage+ColorMasking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+ColorMasking.m"; sourceTree = "<group>"; };
420 6C18C3CC14033DBF0005AA4C /* CocosOverlayScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocosOverlayScrollView.h; sourceTree = "<group>"; };
421 6C18C3CD14033DC10005AA4C /* CocosOverlayScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CocosOverlayScrollView.m; sourceTree = "<group>"; };
422 6C18C3CE14033DC20005AA4C /* NMPanelMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NMPanelMenu.h; sourceTree = "<group>"; };
423 6C18C3CF14033DC30005AA4C /* NMPanelMenu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NMPanelMenu.m; sourceTree = "<group>"; };
424 6C18C3D014033DC40005AA4C /* TouchDelegatingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TouchDelegatingView.h; sourceTree = "<group>"; };
425 6C18C3D114033DC40005AA4C /* TouchDelegatingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TouchDelegatingView.m; sourceTree = "<group>"; };
417 6C29040E13EAEB590032DA0F /* TutorialBubble.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TutorialBubble.h; sourceTree = "<group>"; }; 426 6C29040E13EAEB590032DA0F /* TutorialBubble.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TutorialBubble.h; sourceTree = "<group>"; };
418 6C29040F13EAEB590032DA0F /* TutorialBubble.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TutorialBubble.m; sourceTree = "<group>"; }; 427 6C29040F13EAEB590032DA0F /* TutorialBubble.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TutorialBubble.m; sourceTree = "<group>"; };
419 6C29041113EAEC8A0032DA0F /* framestuff.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = framestuff.png; sourceTree = "<group>"; }; 428 6C29041113EAEC8A0032DA0F /* framestuff.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = framestuff.png; sourceTree = "<group>"; };
@@ -427,6 +436,7 @@
427 6C39D00713FD9037002B21AF /* florence.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = florence.png; sourceTree = "<group>"; }; 436 6C39D00713FD9037002B21AF /* florence.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = florence.png; sourceTree = "<group>"; };
428 6C39D01113FD9945002B21AF /* paris.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = paris.png; sourceTree = "<group>"; }; 437 6C39D01113FD9945002B21AF /* paris.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = paris.png; sourceTree = "<group>"; };
429 6C5179C513DF3839006F1F38 /* Morning1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Morning1.png; sourceTree = "<group>"; }; 438 6C5179C513DF3839006F1F38 /* Morning1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Morning1.png; sourceTree = "<group>"; };
439 6CB532581403BA4F00780A5E /* GameModeSelectionDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameModeSelectionDelegate.h; sourceTree = "<group>"; };
430 6CC89DD813F2F4E6003704F7 /* Entitlements.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Entitlements.plist; sourceTree = "<group>"; }; 440 6CC89DD813F2F4E6003704F7 /* Entitlements.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Entitlements.plist; sourceTree = "<group>"; };
431 6CC89DDD13F31413003704F7 /* TutorialMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TutorialMode.h; sourceTree = "<group>"; }; 441 6CC89DDD13F31413003704F7 /* TutorialMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TutorialMode.h; sourceTree = "<group>"; };
432 6CC89DDE13F31413003704F7 /* TutorialMode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TutorialMode.m; sourceTree = "<group>"; }; 442 6CC89DDE13F31413003704F7 /* TutorialMode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TutorialMode.m; sourceTree = "<group>"; };
@@ -710,6 +720,7 @@
710 2D500B1D0D5A766B00DBA0E3 /* Classes */ = { 720 2D500B1D0D5A766B00DBA0E3 /* Classes */ = {
711 isa = PBXGroup; 721 isa = PBXGroup;
712 children = ( 722 children = (
723 6CB532561403492E00780A5E /* Selection Screen */,
713 6C0C141513F211C7003A31B2 /* Game Modes */, 724 6C0C141513F211C7003A31B2 /* Game Modes */,
714 6C5887E313EE3ED900B5A80A /* Items */, 725 6C5887E313EE3ED900B5A80A /* Items */,
715 E0F81035120A173C005866B8 /* GameConfig.h */, 726 E0F81035120A173C005866B8 /* GameConfig.h */,
@@ -727,12 +738,6 @@
727 3F03221813D7904E00E6A708 /* Highscore.m */, 738 3F03221813D7904E00E6A708 /* Highscore.m */,
728 6C29040E13EAEB590032DA0F /* TutorialBubble.h */, 739 6C29040E13EAEB590032DA0F /* TutorialBubble.h */,
729 6C29040F13EAEB590032DA0F /* TutorialBubble.m */, 740 6C29040F13EAEB590032DA0F /* TutorialBubble.m */,
730 6C39CFF113FD4F87002B21AF /* GameModeSelection.h */,
731 6C39CFF213FD4F89002B21AF /* GameModeSelection.m */,
732 6C39CFF613FD7636002B21AF /* GameModeSelectionLayer.h */,
733 6C39CFF713FD7637002B21AF /* GameModeSelectionLayer.m */,
734 6C18C3C81402AD9C0005AA4C /* UIImage+ColorMasking.h */,
735 6C18C3C91402AD9C0005AA4C /* UIImage+ColorMasking.m */,
736 ); 741 );
737 path = Classes; 742 path = Classes;
738 sourceTree = "<group>"; 743 sourceTree = "<group>";
@@ -929,6 +934,26 @@
929 name = Items; 934 name = Items;
930 sourceTree = "<group>"; 935 sourceTree = "<group>";
931 }; 936 };
937 6CB532561403492E00780A5E /* Selection Screen */ = {
938 isa = PBXGroup;
939 children = (
940 6C39CFF113FD4F87002B21AF /* GameModeSelection.h */,
941 6C39CFF213FD4F89002B21AF /* GameModeSelection.m */,
942 6C39CFF613FD7636002B21AF /* GameModeSelectionLayer.h */,
943 6C39CFF713FD7637002B21AF /* GameModeSelectionLayer.m */,
944 6C18C3C81402AD9C0005AA4C /* UIImage+ColorMasking.h */,
945 6C18C3C91402AD9C0005AA4C /* UIImage+ColorMasking.m */,
946 6C18C3CC14033DBF0005AA4C /* CocosOverlayScrollView.h */,
947 6C18C3CD14033DC10005AA4C /* CocosOverlayScrollView.m */,
948 6C18C3CE14033DC20005AA4C /* NMPanelMenu.h */,
949 6C18C3CF14033DC30005AA4C /* NMPanelMenu.m */,
950 6C18C3D014033DC40005AA4C /* TouchDelegatingView.h */,
951 6C18C3D114033DC40005AA4C /* TouchDelegatingView.m */,
952 6CB532581403BA4F00780A5E /* GameModeSelectionDelegate.h */,
953 );
954 name = "Selection Screen";
955 sourceTree = "<group>";
956 };
932 E02BBB19126CC2F5006E46A2 /* cocos2d */ = { 957 E02BBB19126CC2F5006E46A2 /* cocos2d */ = {
933 isa = PBXGroup; 958 isa = PBXGroup;
934 children = ( 959 children = (
@@ -1445,6 +1470,9 @@
1445 6C39CFF313FD4F8B002B21AF /* GameModeSelection.m in Sources */, 1470 6C39CFF313FD4F8B002B21AF /* GameModeSelection.m in Sources */,
1446 6C39CFF813FD7638002B21AF /* GameModeSelectionLayer.m in Sources */, 1471 6C39CFF813FD7638002B21AF /* GameModeSelectionLayer.m in Sources */,
1447 6C18C3CA1402AD9C0005AA4C /* UIImage+ColorMasking.m in Sources */, 1472 6C18C3CA1402AD9C0005AA4C /* UIImage+ColorMasking.m in Sources */,
1473 6C18C3D214033DC50005AA4C /* CocosOverlayScrollView.m in Sources */,
1474 6C18C3D314033DC60005AA4C /* NMPanelMenu.m in Sources */,
1475 6C18C3D414033DC60005AA4C /* TouchDelegatingView.m in Sources */,
1448 ); 1476 );
1449 runOnlyForDeploymentPostprocessing = 0; 1477 runOnlyForDeploymentPostprocessing = 0;
1450 }; 1478 };
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