summary refs log tree commit diff stats
path: root/Classes/PauseLayer.m
blob: 53574b2c5f90691a9c9929d8aab7cf1c66c87092 (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
//
//  PauseLayer.m
//  Cart Collect
//
//  Created by iD Student Account on 7/20/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "PauseLayer.h"

@implementation PauseLayer

+ (CCScene*)sceneWithScene:(CCScene*)scene2
{
	CCScene* scene = [CCScene node];
	
	CCLayerColor* backgroundLayer = [CCLayerColor layerWithColor:ccc4(255, 255, 255, 255)];
	CCSprite* backgroundImage = [CCSprite spriteWithFile:@"SeaBeach.png"];
	backgroundImage.position = ccp(240,160);
	[backgroundLayer addChild:backgroundImage];
	[scene addChild:backgroundLayer];
	
	CCLayerColor* backgroundLayer2 = [CCLayerColor layerWithColor:ccc4(0, 0, 0, 127)];
	[scene addChild:backgroundLayer2];
	
	PauseLayer* layer = [[[PauseLayer alloc] initWithScene:scene2] autorelease];
	[scene addChild:layer];
	
	return scene;
}

- (id)initWithScene:(CCScene*)scene
{
	self = [super init];
	
	if (nil != self)
	{
		game = [scene retain];
		
		CCLabelBMFont* scoreLabel = [CCLabelBMFont labelWithString:@"PAUSE" fntFile:@"helvetica.fnt"];
		scoreLabel.position = ccp(240,90);
		[self addChild:scoreLabel];
		
		CCMenuItemImage* pauseButton = [CCMenuItemImage itemFromNormalImage:@"pause2.png" selectedImage:@"pause.png" target:self selector:@selector(unpause)];
		CCMenu* pauseMenu = [CCMenu menuWithItems:pauseButton, nil];
		[pauseMenu setPosition:ccp(480-8-16, 320-8-16)];
		[self addChild:pauseMenu];
        
        CCMenuItemImage* newgameMenuItem = [CCMenuItemImage itemFromNormalImage:@"back.png" selectedImage:@"back2.png" target:self selector:@selector(newgame)];
		CCMenu* myMenu = [CCMenu menuWithItems:newgameMenuItem, nil];
		myMenu.position = ccp(240, 60);
		[self addChild:myMenu];
	}
	
	return self;
}

- (void)unpause
{
	[[CCDirector sharedDirector] replaceScene:game];
}

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

@end