summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2011-08-15 14:47:39 -0400
committerStarla Insigna <starla4444@gmail.com>2011-08-15 14:47:39 -0400
commitc55c499656ed089df63b049979487e9af9d109d6 (patch)
treea07f86c4630ad35e10304c50c6ef562f56424c91
parent4457e0ce5099a81f8e6a366e353561b886725532 (diff)
downloadcartcollect-c55c499656ed089df63b049979487e9af9d109d6.tar.gz
cartcollect-c55c499656ed089df63b049979487e9af9d109d6.tar.bz2
cartcollect-c55c499656ed089df63b049979487e9af9d109d6.zip
Fixed game over transition
Fixes #189
-rwxr-xr-xCart Collect.xcodeproj/project.pbxproj12
-rwxr-xr-xClasses/ClassicGameMode.m4
-rwxr-xr-xClasses/GameOverScene.h (renamed from Classes/GameOverLayer.h)6
-rwxr-xr-xClasses/GameOverScene.m (renamed from Classes/GameOverLayer.m)64
4 files changed, 43 insertions, 43 deletions
diff --git a/Cart Collect.xcodeproj/project.pbxproj b/Cart Collect.xcodeproj/project.pbxproj index bd63c09..280cb2a 100755 --- a/Cart Collect.xcodeproj/project.pbxproj +++ b/Cart Collect.xcodeproj/project.pbxproj
@@ -39,7 +39,7 @@
39 3F6C7EC613D6335A00C038FE /* 1up.wav in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7EC513D6335A00C038FE /* 1up.wav */; }; 39 3F6C7EC613D6335A00C038FE /* 1up.wav in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7EC513D6335A00C038FE /* 1up.wav */; };
40 3F6C7EE113D636BE00C038FE /* rock.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7EE013D636BE00C038FE /* rock.png */; }; 40 3F6C7EE113D636BE00C038FE /* rock.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7EE013D636BE00C038FE /* rock.png */; };
41 3F6C7EE413D636CF00C038FE /* Rock.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F6C7EE313D636CF00C038FE /* Rock.m */; }; 41 3F6C7EE413D636CF00C038FE /* Rock.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F6C7EE313D636CF00C038FE /* Rock.m */; };
42 3F6C7EE913D6377D00C038FE /* GameOverLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F6C7EE813D6377D00C038FE /* GameOverLayer.m */; }; 42 3F6C7EE913D6377D00C038FE /* GameOverScene.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F6C7EE813D6377D00C038FE /* GameOverScene.m */; };
43 3F6C7F2413D63E6500C038FE /* SeaBeach.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7F2313D63E6500C038FE /* SeaBeach.png */; }; 43 3F6C7F2413D63E6500C038FE /* SeaBeach.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7F2313D63E6500C038FE /* SeaBeach.png */; };
44 3F6C7F4B13D647A600C038FE /* GameOver.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7F4A13D647A600C038FE /* GameOver.png */; }; 44 3F6C7F4B13D647A600C038FE /* GameOver.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7F4A13D647A600C038FE /* GameOver.png */; };
45 3F6C7F5B13D648CE00C038FE /* helvetica2.fnt in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7F5913D648CE00C038FE /* helvetica2.fnt */; }; 45 3F6C7F5B13D648CE00C038FE /* helvetica2.fnt in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7F5913D648CE00C038FE /* helvetica2.fnt */; };
@@ -342,8 +342,8 @@
342 3F6C7EE013D636BE00C038FE /* rock.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = rock.png; sourceTree = "<group>"; }; 342 3F6C7EE013D636BE00C038FE /* rock.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = rock.png; sourceTree = "<group>"; };
343 3F6C7EE213D636CF00C038FE /* Rock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Rock.h; sourceTree = "<group>"; }; 343 3F6C7EE213D636CF00C038FE /* Rock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Rock.h; sourceTree = "<group>"; };
344 3F6C7EE313D636CF00C038FE /* Rock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Rock.m; sourceTree = "<group>"; }; 344 3F6C7EE313D636CF00C038FE /* Rock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Rock.m; sourceTree = "<group>"; };
345 3F6C7EE713D6377D00C038FE /* GameOverLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameOverLayer.h; sourceTree = "<group>"; }; 345 3F6C7EE713D6377D00C038FE /* GameOverScene.h */ = {isa = PBXFileReference; fileEncoding = 4; path = GameOverScene.h; sourceTree = "<group>"; };
346 3F6C7EE813D6377D00C038FE /* GameOverLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameOverLayer.m; sourceTree = "<group>"; }; 346 3F6C7EE813D6377D00C038FE /* GameOverScene.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameOverScene.m; sourceTree = "<group>"; };
347 3F6C7F2313D63E6500C038FE /* SeaBeach.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = SeaBeach.png; sourceTree = "<group>"; }; 347 3F6C7F2313D63E6500C038FE /* SeaBeach.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = SeaBeach.png; sourceTree = "<group>"; };
348 3F6C7F4A13D647A600C038FE /* GameOver.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = GameOver.png; sourceTree = "<group>"; }; 348 3F6C7F4A13D647A600C038FE /* GameOver.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = GameOver.png; sourceTree = "<group>"; };
349 3F6C7F5913D648CE00C038FE /* helvetica2.fnt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = helvetica2.fnt; sourceTree = "<group>"; }; 349 3F6C7F5913D648CE00C038FE /* helvetica2.fnt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = helvetica2.fnt; sourceTree = "<group>"; };
@@ -702,8 +702,8 @@
702 E0F81037120A173C005866B8 /* RootViewController.m */, 702 E0F81037120A173C005866B8 /* RootViewController.m */,
703 1F3B9A2C0EF2145700286867 /* Cart_CollectAppDelegate.h */, 703 1F3B9A2C0EF2145700286867 /* Cart_CollectAppDelegate.h */,
704 507022A2107672FA00393637 /* Cart_CollectAppDelegate.m */, 704 507022A2107672FA00393637 /* Cart_CollectAppDelegate.m */,
705 3F6C7EE713D6377D00C038FE /* GameOverLayer.h */, 705 3F6C7EE713D6377D00C038FE /* GameOverScene.h */,
706 3F6C7EE813D6377D00C038FE /* GameOverLayer.m */, 706 3F6C7EE813D6377D00C038FE /* GameOverScene.m */,
707 3F83955213D739B10059AEE8 /* MainMenuLayer.m */, 707 3F83955213D739B10059AEE8 /* MainMenuLayer.m */,
708 3F83955113D739B10059AEE8 /* MainMenuLayer.h */, 708 3F83955113D739B10059AEE8 /* MainMenuLayer.h */,
709 3F03221413D78F8C00E6A708 /* HighscoreListController.h */, 709 3F03221413D78F8C00E6A708 /* HighscoreListController.h */,
@@ -1398,7 +1398,7 @@
1398 3F6C7C7013D5E54E00C038FE /* Bottle.m in Sources */, 1398 3F6C7C7013D5E54E00C038FE /* Bottle.m in Sources */,
1399 3F6C7C7313D5E57100C038FE /* OneUp.m in Sources */, 1399 3F6C7C7313D5E57100C038FE /* OneUp.m in Sources */,
1400 3F6C7EE413D636CF00C038FE /* Rock.m in Sources */, 1400 3F6C7EE413D636CF00C038FE /* Rock.m in Sources */,
1401 3F6C7EE913D6377D00C038FE /* GameOverLayer.m in Sources */, 1401 3F6C7EE913D6377D00C038FE /* GameOverScene.m in Sources */,
1402 3F83955313D739B10059AEE8 /* MainMenuLayer.m in Sources */, 1402 3F83955313D739B10059AEE8 /* MainMenuLayer.m in Sources */,
1403 3F03221613D78F8C00E6A708 /* HighscoreListController.m in Sources */, 1403 3F03221613D78F8C00E6A708 /* HighscoreListController.m in Sources */,
1404 3F03221913D7904E00E6A708 /* Highscore.m in Sources */, 1404 3F03221913D7904E00E6A708 /* Highscore.m in Sources */,
diff --git a/Classes/ClassicGameMode.m b/Classes/ClassicGameMode.m index eb766a1..88c52ce 100755 --- a/Classes/ClassicGameMode.m +++ b/Classes/ClassicGameMode.m
@@ -12,7 +12,7 @@
12#import "Bottle.h" 12#import "Bottle.h"
13#import "OneUp.h" 13#import "OneUp.h"
14#import "Rock.h" 14#import "Rock.h"
15#import "GameOverLayer.h" 15#import "GameOverScene.h"
16#import "SimpleAudioEngine.h" 16#import "SimpleAudioEngine.h"
17 17
18@implementation ClassicGameMode 18@implementation ClassicGameMode
@@ -27,7 +27,7 @@
27 { 27 {
28 [self unscheduleAllSelectors]; 28 [self unscheduleAllSelectors];
29 29
30 [[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInT transitionWithDuration:1.5f scene:[GameOverLayer sceneWithScore:score]]]; 30 [[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInT transitionWithDuration:1.5f scene:[GameOverScene sceneWithScore:score]]];
31 } else if (score > lastScore) 31 } else if (score > lastScore)
32 { 32 {
33 if ((lastScore < 6500) && (score >= 6500)) 33 if ((lastScore < 6500) && (score >= 6500))
diff --git a/Classes/GameOverLayer.h b/Classes/GameOverScene.h index c800e82..ef63aa7 100755 --- a/Classes/GameOverLayer.h +++ b/Classes/GameOverScene.h
@@ -9,7 +9,9 @@
9#import <Foundation/Foundation.h> 9#import <Foundation/Foundation.h>
10#import "cocos2d.h" 10#import "cocos2d.h"
11 11
12@interface GameOverLayer : CCLayer <UITextFieldDelegate, UIAlertViewDelegate> { 12@interface GameOverScene : CCScene <UITextFieldDelegate, UIAlertViewDelegate> {
13 CCLayer* theLayer;
14 UIView* movingLayer;
13 UILabel* scoreField; 15 UILabel* scoreField;
14 UITextField* textField; 16 UITextField* textField;
15 UISwitch* submitSwitch; 17 UISwitch* submitSwitch;
@@ -18,7 +20,7 @@
18 int score; 20 int score;
19} 21}
20 22
21+ (CCScene*)sceneWithScore:(int)score; 23+ (GameOverScene*)sceneWithScore:(int)score;
22- (id)initWithScore:(int)score; 24- (id)initWithScore:(int)score;
23- (void)newgame; 25- (void)newgame;
24- (void)submitScore; 26- (void)submitScore;
diff --git a/Classes/GameOverLayer.m b/Classes/GameOverScene.m index 9f58f01..bc081ff 100755 --- a/Classes/GameOverLayer.m +++ b/Classes/GameOverScene.m
@@ -6,85 +6,80 @@
6// Copyright 2011 __MyCompanyName__. All rights reserved. 6// Copyright 2011 __MyCompanyName__. All rights reserved.
7// 7//
8 8
9#import "GameOverLayer.h" 9#import "GameOverScene.h"
10#import "Cart_CollectAppDelegate.h" 10#import "Cart_CollectAppDelegate.h"
11#import <sqlite3.h> 11#import <sqlite3.h>
12#import "cocoslive.h" 12#import "cocoslive.h"
13#import "MainMenuLayer.h" 13#import "MainMenuLayer.h"
14 14
15@implementation GameOverLayer 15@implementation GameOverScene
16 16
17+ (CCScene*)sceneWithScore:(int)score 17+ (GameOverScene*)sceneWithScore:(int)score
18{ 18{
19 CCScene* scene = [CCScene node]; 19 return [[[GameOverScene alloc] initWithScore:score] autorelease];
20
21 CCLayerColor* backgroundLayer = [CCLayerColor layerWithColor:ccc4(255, 255, 255, 255)];
22 [scene addChild:backgroundLayer];
23
24 GameOverLayer* layer = [[[GameOverLayer alloc] initWithScore:score] autorelease];
25 [scene addChild:layer];
26
27 return scene;
28} 20}
29 21
30- (id)initWithScore:(int)score2 22- (id)initWithScore:(int)score2
31{ 23{
32 self = [super init]; 24 self = [super init];
33 25
34 if (nil != self) 26 if (nil != self)
35 { 27 {
28 CCLayerColor* backgroundLayer = [CCLayerColor layerWithColor:ccc4(255, 255, 255, 255)];
29 [self addChild:backgroundLayer];
30
31 theLayer = [CCLayer node];
32 [self addChild:theLayer];
33
36 CCSprite* backgroundImage = [CCSprite spriteWithFile:@"Morning1.png"]; 34 CCSprite* backgroundImage = [CCSprite spriteWithFile:@"Morning1.png"];
37 backgroundImage.position = ccp(240, 160); 35 backgroundImage.position = ccp(240, 160);
38 [self addChild:backgroundImage z:0]; 36 [theLayer addChild:backgroundImage z:0];
39 37
40 score = score2; 38 score = score2;
41 39
42 scoreField = [[UILabel alloc] initWithFrame:CGRectMake(205, 320-200-320, 0, 0)]; 40 movingLayer = [[UIView alloc] initWithFrame:CGRectMake(0, -320, 480, 320)];
41 movingLayer.backgroundColor = [UIColor clearColor];
42 [[[CCDirector sharedDirector] openGLView] addSubview:movingLayer];
43
44 scoreField = [[UILabel alloc] initWithFrame:CGRectMake(205, 320-200, 0, 0)];
43 [scoreField setFont:[UIFont systemFontOfSize:20.0f]]; 45 [scoreField setFont:[UIFont systemFontOfSize:20.0f]];
44 [scoreField setBackgroundColor:[UIColor clearColor]]; 46 [scoreField setBackgroundColor:[UIColor clearColor]];
45 [scoreField setText:[NSString stringWithFormat:@"%d", score2]]; 47 [scoreField setText:[NSString stringWithFormat:@"%d", score2]];
46 CGSize labelSize = [scoreField.text sizeWithFont:scoreField.font constrainedToSize:CGSizeMake(160, 31) lineBreakMode:UILineBreakModeClip]; 48 CGSize labelSize = [scoreField.text sizeWithFont:scoreField.font constrainedToSize:CGSizeMake(160, 31) lineBreakMode:UILineBreakModeClip];
47 [scoreField setFrame:CGRectMake(scoreField.frame.origin.x, scoreField.frame.origin.y, labelSize.width, labelSize.height)]; 49 [scoreField setFrame:CGRectMake(scoreField.frame.origin.x, scoreField.frame.origin.y, labelSize.width, labelSize.height)];
48 [[[CCDirector sharedDirector] openGLView] addSubview:scoreField]; 50 [movingLayer addSubview:scoreField];
49 51
50 textField = [[UITextField alloc] initWithFrame:CGRectMake(205, 320-247-320, 216, 31)]; 52 textField = [[UITextField alloc] initWithFrame:CGRectMake(205, 320-247, 216, 31)];
51 [textField setFont:[UIFont systemFontOfSize:20.0f]]; 53 [textField setFont:[UIFont systemFontOfSize:20.0f]];
52 [textField setBackgroundColor:[UIColor clearColor]]; 54 [textField setBackgroundColor:[UIColor clearColor]];
53 [textField setDelegate:self]; 55 [textField setDelegate:self];
54 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; 56 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
55 [textField setText:[defaults objectForKey:@"username"]]; 57 [textField setText:[defaults objectForKey:@"username"]];
56 [[[CCDirector sharedDirector] openGLView] addSubview:textField]; 58 [movingLayer addSubview:textField];
57 59
58 submitSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(211, 320-161-320, 0, 0)]; 60 submitSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(211, 320-161, 0, 0)];
59 [submitSwitch setOn:[defaults boolForKey:@"submitScore"]]; 61 [submitSwitch setOn:[defaults boolForKey:@"submitScore"]];
60 [[[CCDirector sharedDirector] openGLView] addSubview:submitSwitch]; 62 [movingLayer addSubview:submitSwitch];
61 63
62 activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(480-20-10, 320-20-10, 20, 20)]; 64 activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(480-20-10, 320-20-10, 20, 20)];
63 [[[CCDirector sharedDirector] openGLView] addSubview:activityIndicator]; 65 [movingLayer addSubview:activityIndicator];
64 66
65 backButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 67 backButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
66 [backButton setFrame:CGRectMake(240-154/2, 320-60-15-320, 154, 31)]; 68 [backButton setFrame:CGRectMake(240-154/2, 320-60-15, 154, 31)];
67 [backButton setTitle:@"Back to Main Menu" forState:UIControlStateNormal]; 69 [backButton setTitle:@"Back to Main Menu" forState:UIControlStateNormal];
68 [backButton addTarget:self action:@selector(newgame) forControlEvents:UIControlEventTouchUpInside]; 70 [backButton addTarget:self action:@selector(newgame) forControlEvents:UIControlEventTouchUpInside];
69 [backButton.titleLabel setFont:[UIFont systemFontOfSize:16.0]]; 71 [backButton.titleLabel setFont:[UIFont systemFontOfSize:16.0]];
70 [backButton.titleLabel setTextColor:[UIColor blackColor]]; 72 [backButton.titleLabel setTextColor:[UIColor blackColor]];
71 73 [movingLayer addSubview:backButton];
72 [[[CCDirector sharedDirector] openGLView] addSubview:backButton];
73 } 74 }
74 75
75 return self; 76 return self;
76} 77}
77 78
78- (void)onEnter 79- (void)setPosition:(CGPoint)position
79{ 80{
80 [UIView beginAnimations:nil context:NULL]; 81 [super setPosition:position];
81 [UIView setAnimationDuration:1.5f]; 82 movingLayer.center = CGPointMake(240, 160-position.y);
82 [UIView setAnimationCurve:UIViewAnimationCurveLinear];
83 scoreField.transform = CGAffineTransformMakeTranslation(0, 320);
84 textField.transform = CGAffineTransformMakeTranslation(0, 320);
85 submitSwitch.transform = CGAffineTransformMakeTranslation(0, 320);
86 backButton.transform = CGAffineTransformMakeTranslation(0, 320);
87 [UIView commitAnimations];
88} 83}
89 84
90- (void)newgame 85- (void)newgame
@@ -192,6 +187,9 @@
192 [activityIndicator release]; 187 [activityIndicator release];
193 188
194 [backButton removeFromSuperview]; 189 [backButton removeFromSuperview];
190
191 [movingLayer removeFromSuperview];
192 [movingLayer release];
195 193
196 [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]]; 194 [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]];
197} 195}