summary refs log tree commit diff stats
path: root/Classes/MainMenuLayer.m
blob: 11cffd7b1d336317b3dc3781a20d9f4f679a8399 (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
//
//  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 "GameLayer.h"
#import "Cart_CollectAppDelegate.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* menuItem1 = [CCMenuItemImage itemFromNormalImage:@"newgame.png" selectedImage:@"newgame2.png" target:self selector:@selector(newgame)];
		CCMenuItemImage* menuItem2 = [CCMenuItemImage itemFromNormalImage:@"highscores.png" selectedImage:@"highscores2.png" target:self selector:@selector(highscores)];
		
		CCMenu* menu = [CCMenu menuWithItems:menuItem1, menuItem2, nil];
		[menu alignItemsVertically];
		menu.position = ccp(240, 100);
		[self addChild:menu];
	}
	
	return self;
}

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

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

@end