-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameOverLayer.m
executable file
·48 lines (40 loc) · 1.39 KB
/
GameOverLayer.m
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
//
// GameOverLayer.m
// PhantomAssasins
//
// Created by Agustin Marseillan on 9/19/13.
// Copyright 2013 Agustin Marseillan. All rights reserved.
//
#import "GameOverLayer.h"
#import "MainLoopLayer.h"
@implementation GameOverLayer
+(CCScene *) sceneWithWon:(BOOL)won status:(AGGameStatus*)status{
CCScene *scene = [CCScene node];
GameOverLayer *layer = [[GameOverLayer alloc] initWithWon:won status:status];
[scene addChild: layer];
return scene;
}
- (id)initWithWon:(BOOL)won status:(AGGameStatus*)status{
if ((self = [super initWithColor:ccc4(255, 255, 255, 255)])) {
NSString * message;
if (won) {
message = @"You Won!";
} else {
message = [NSString stringWithFormat:@"You Lose :[, won %d gold", status.gold];
}
CGSize winSize = [[CCDirector sharedDirector] winSize];
CCLabelTTF * label = [CCLabelTTF labelWithString:message fontName:@"Arial" fontSize:32];
label.color = ccc3(0,0,0);
label.position = ccp(winSize.width/2, winSize.height/2);
[self addChild:label];
[self runAction:
[CCSequence actions:
[CCDelayTime actionWithDuration:3],
[CCCallBlockN actionWithBlock:^(CCNode *node) {
[[CCDirector sharedDirector] replaceScene:[MainLoopLayer scene:status]];
}],
nil]];
}
return self;
}
@end