-
Notifications
You must be signed in to change notification settings - Fork 0
/
PauseScene.m
96 lines (82 loc) · 2.5 KB
/
PauseScene.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
79
80
81
82
83
84
85
86
87
88
89
90
91
//
// PauseScene.m
//
// Created by : Michael Heirendt
// Project : Crush
// Date : 1/2/16
//
// Copyright (c) 2016 Apportable.
// All rights reserved.
//
// -----------------------------------------------------------------
#import "PauseScene.h"
#import "GameData.h"
#import "AlertView.h"
// -----------------------------------------------------------------
@implementation PauseScene{
CCNode *pauseNode;
CCLabelTTF *user;
CCLabelTTF *rank;
CCSprite *icon;
CCProgressNode *_progressNode;
CCSprite *progress;
id block;
CCButton *play;
CCButton *restart;
CCButton *quit;
}
// -----------------------------------------------------------------
+ (instancetype)node
{
return [[self alloc] init];
}
- (instancetype)init
{
self = [super init];
NSAssert(self, @"Unable to create class %@", [self class]);
return self;
}
-(void)onEnter{
[super onEnter];
[[GameData sharedGameData]summarizeRank:rank andUser:user andRankIcon:icon];
}
-(void)resumePressed{
[[CCDirector sharedDirector] popScene];
}
-(void)restartPressed{
play.enabled = false;
restart.enabled = false;
quit.enabled = false;
[AlertView ShowAlert:@"Are you sure you want to restart? All progress will be lost." onLayer:self withOpt1:@"Yes" withOpt1Block:^(void){
[GameData sharedGameData].roundScore = 0;
[[GameData sharedGameData] reset];
[[CCDirector sharedDirector] popScene];
[[CCDirector sharedDirector] popScene];
CCScene *game = [CCBReader loadAsScene:@"Gameplay"];
[[CCDirector sharedDirector] pushScene:game];
} andOpt2:@"Cancel" withOpt2Block:^(void){
play.enabled = true;
restart.enabled = true;
quit.enabled = true;
}];
}
-(void)quitPressed{
play.enabled = false;
restart.enabled = false;
quit.enabled = false;
[AlertView ShowAlert:@"Are you sure you want to quit? All progress will be lost." onLayer:self withOpt1:@"Yes" withOpt1Block:^(void){
[GameData sharedGameData].roundScore = 0;
[[GameData sharedGameData]reset];
[[CCDirector sharedDirector] popScene];
[[CCDirector sharedDirector] popScene];
if ([GameData sharedGameData].newPlayerFlag){
[GameData sharedGameData].newPlayerFlag = false;
}
} andOpt2:@"Cancel" withOpt2Block:^(void){
play.enabled = true;
restart.enabled = true;
quit.enabled = true;
}];
}
// -----------------------------------------------------------------
@end