-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEndGameScene.m
78 lines (66 loc) · 3.04 KB
/
EndGameScene.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
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
//
// EndGameScene.m
// JumboJump
//
// Created by David Pointeau on 24/04/14.
// Copyright (c) 2014 David Pointeau. All rights reserved.
//
#import "EndGameScene.h"
#import "MyScene.h"
@implementation EndGameScene
- (id) initWithSize:(CGSize)size
{
if (self = [super initWithSize:size]) {
// Stars
SKSpriteNode *star = [SKSpriteNode spriteNodeWithImageNamed:@"Star"];
star.position = CGPointMake(25, self.size.height-30);
[self addChild:star];
SKLabelNode *lblStars = [SKLabelNode labelNodeWithFontNamed:@"ChalkboardSE-Bold"];
lblStars.fontSize = 30;
lblStars.fontColor = [SKColor whiteColor];
lblStars.position = CGPointMake(50, self.size.height-40);
lblStars.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeLeft;
[lblStars setText:[NSString stringWithFormat:@"X %d", [GameState sharedInstance].stars]];
[self addChild:lblStars];
// Score
SKLabelNode *lblScore = [SKLabelNode labelNodeWithFontNamed:@"ChalkboardSE-Bold"];
lblScore.fontSize = 60;
lblScore.fontColor = [SKColor whiteColor];
lblScore.position = CGPointMake(160, 300);
lblScore.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeCenter;
[lblScore setText:[NSString stringWithFormat:@"%d", [GameState sharedInstance].score]];
[self addChild:lblScore];
// High Score
SKLabelNode *lblHighScore = [SKLabelNode labelNodeWithFontNamed:@"ChalkboardSE-Bold"];
lblHighScore.fontSize = 30;
lblHighScore.fontColor = [SKColor cyanColor];
lblHighScore.position = CGPointMake(160, 150);
lblHighScore.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeCenter;
[lblHighScore setText:[NSString stringWithFormat:@"Jumbo Score: %d", [GameState sharedInstance].highScore]];
[self addChild:lblHighScore];
// Try again
SKLabelNode *lblTryAgain = [SKLabelNode labelNodeWithFontNamed:@"ChalkboardSE-Bold"];
lblTryAgain.fontSize = 30;
lblTryAgain.fontColor = [SKColor whiteColor];
lblTryAgain.position = CGPointMake(160, 90);
lblTryAgain.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeCenter;
[lblTryAgain setText:@"Tap To Try Again"];
[self addChild:lblTryAgain];
SKLabelNode *lblcopyright = [SKLabelNode labelNodeWithFontNamed:@"SavoyeLetPlain"];
lblcopyright.fontSize = 15;
lblcopyright.fontColor = [SKColor whiteColor];
lblcopyright.position = CGPointMake(160, 40);
lblcopyright.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeCenter;
[lblcopyright setText:@"By David P & Harry O"];
[self addChild:lblcopyright];
}
return self;
}
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// Transition back to the Game
SKScene *myScene = [[MyScene alloc] initWithSize:self.size];
SKTransition *reveal = [SKTransition fadeWithDuration:0.5];
[self.view presentScene:myScene transition:reveal];
}
@end