summary refs log tree commit diff stats
path: root/Classes/GameModeSelection.m
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2011-08-23 07:52:24 -0400
committerStarla Insigna <starla4444@gmail.com>2011-08-23 07:52:24 -0400
commitc9337218ef1660360097928c753bde1c79775618 (patch)
tree3cd6f9926cbe092c98776673800b830eef27ca01 /Classes/GameModeSelection.m
parent2ac50443ddbf69b7594808ba4e6de49eecbc0b84 (diff)
downloadcartcollect-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/GameModeSelection.m')
-rw-r--r--Classes/GameModeSelection.m35
1 files changed, 25 insertions, 10 deletions
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];