diff options
Diffstat (limited to 'Classes')
| -rwxr-xr-x | Classes/ClassicGameMode.m | 4 | ||||
| -rwxr-xr-x | Classes/GameOverScene.h (renamed from Classes/GameOverLayer.h) | 6 | ||||
| -rwxr-xr-x | Classes/GameOverScene.m (renamed from Classes/GameOverLayer.m) | 64 |
3 files changed, 37 insertions, 37 deletions
| 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 | } |
