summary refs log tree commit diff stats
path: root/Classes/MainMenuLayer.m
blob: cf4b8cf7e6b5c46e85b06ca747cf18d912c16116 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
//  MainMenuLayer.m
//  Cart Collect
//
//  Created by iD Student Account on 7/20/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "MainMenuLayer.h"
#import "HighscoreListController.h"
#import "ClassicGameMode.h"
#import "TutorialMode.h"
#import "Cart_CollectAppDelegate.h"
#import "JumpGameMode.h"

@implementation MainMenuLayer

+ (CCScene*)scene
{
	CCScene* scene = [CCScene node];
	
	MainMenuLayer* layer = [MainMenuLayer node];
	[scene addChild:layer];
	
	return scene;
}

- (id)init
{
	self = [super init];
	 
	if (nil != self)
	{
		CCSprite* backgroundImage = [CCSprite spriteWithFile:@"SeaBeach.png"];
		backgroundImage.position = ccp(240,160);
		[self addChild:backgroundImage];
		
		CCLabelBMFont* titleText = [CCLabelBMFont labelWithString:@"Cart Collect - The Game!" fntFile:@"getoffthatboatrightnowyounglady.fnt"];
		titleText.position = ccp(240, 320-64);
		[self addChild:titleText];
		
		//CCLabelBMFont* menuItemLabel1 = [CCLabelBMFont labelWithString:@"New Game" fntFile:@"getoffthatboatrightnowyounglady.fnt"];
		//CCMenuItemLabel* menuItem1 = [CCMenuItemLabel itemWithLabel:menuItemLabel1 target:self selector:@selector(newgame)];
		
		//CCLabelBMFont* menuItemLabel2 = [CCLabelBMFont labelWithString:@"Highscores" fntFile:@"getoffthatboatrightnowyounglady.fnt"];
		//CCMenuItemLabel* menuItem2 = [CCMenuItemLabel itemWithLabel:menuItemLabel2 target:self selector:@selector(highscores)];
		
		CCMenuItemImage* newgameMenuItem = [CCMenuItemImage itemFromNormalImage:@"newgame.png" selectedImage:@"newgame2.png" target:self selector:@selector(newgame)];
        CCMenuItemImage* tutorialMenuItem = [CCMenuItemImage itemFromNormalImage:@"tutorial.png" selectedImage:@"tutorial2.png" target:self selector:@selector(tutorial)];
        CCMenuItemImage* jumpMenuItem = [CCMenuItemImage itemFromNormalImage:@"jump.png" selectedImage:@"jump2.png" target:self selector:@selector(jump)];
		CCMenuItemImage* highscoresMenuItem = [CCMenuItemImage itemFromNormalImage:@"highscores.png" selectedImage:@"highscores2.png" target:self selector:@selector(highscores)];
		
		CCMenu* menu = [CCMenu menuWithItems:newgameMenuItem, tutorialMenuItem, jumpMenuItem, highscoresMenuItem, nil];
		[menu alignItemsVertically];
		menu.position = ccp(240, 100);
		[self addChild:menu];
	}
	
	return self;
}

- (void)newgame
{
    [[CCDirector sharedDirector] replaceScene:[ClassicGameMode scene]];
}

- (void)tutorial
{
    [[CCDirector sharedDirector] replaceScene:[TutorialMode scene]];
}

- (void)jump
{
    [[CCDirector sharedDirector] replaceScene:[JumpGameMode scene]];
}

- (void)highscores
{
	HighscoreListController* listController = [[HighscoreListController alloc] initWithStyle:UITableViewStylePlain];
    Cart_CollectAppDelegate* appDelegate = ((Cart_CollectAppDelegate*) [[UIApplication sharedApplication] delegate]);
	[[appDelegate window] setRootViewController:listController];
    [listController release];
}

@end