#import "SimpleAudioEngine.h"
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"background-music-aac.caf"];
[[SimpleAudioEngine sharedEngine] playEffect:@"pew-pew-lei.caf"];
@interface GameOverLayer : CCColorLayer {
CCLabel *_label;
}
@property (nonatomic, retain) CCLabel *label;
@end
@interface GameOverScene : CCScene {
GameOverLayer *_layer;
}
@property (nonatomic, retain) GameOverLayer *layer;
@end
#import "GameOverScene.h"
#import "MammothHuntingScene.h"
@implementation GameOverLayer
@synthesize label = _label;
-(id) init {
if ((self=[super initWithColor:ccc4(255,255,255,255)])) {
CGSize winSize = [[CCDirector sharedDirector] winSize];
self.label = [CCLabel labelWithString:@"" 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],
[CCCallFunc actionWithTarget:self selector:@selector(gameOverDone)],
nil]];
}
return self;
}
- (void)gameOverDone {
[[CCDirector sharedDirector] replaceScene:[MammothHuntingScene scene]];
}
- (void)dealloc {
[_label release];
_label = nil;
[super dealloc];
}
@end
@implementation GameOverScene
@synthesize layer = _layer;
- (id)init {
if ((self = [super init])) {
self.layer = [GameOverLayer node];
[self addChild:_layer];
}
return self;
}
- (void)dealloc {
[_layer release];
_layer = nil;
[super dealloc];
}
@end
int _projectilesDestroyed;
#import "GameOverScene.h"
_projectilesDestroyed++;
if (_projectilesDestroyed > 30) {
GameOverScene *gameOverScene = [GameOverScene node];
[gameOverScene.layer.label setString:@"You Win!"];
[[CCDirector sharedDirector] replaceScene:gameOverScene];
}
GameOverScene *gameOverScene = [GameOverScene node];
[gameOverScene.layer.label setString:@"You Lose :["];
[[CCDirector sharedDirector] replaceScene:gameOverScene];
'프로그래밍 > Cocos2D' 카테고리의 다른 글
Cocos2D FAQ (0) | 2012.01.29 |
---|---|
Cocos2D #1 - Cocos2D 튜터리얼로 간단한 아이폰 게임 만들기 (0) | 2010.07.28 |
[MammothHunting] - Cocos2D를 사용한 아이폰 게임 개발 튜토리얼 3 (0) | 2010.07.02 |
[MammothHunting] - Cocos2D를 사용한 아이폰 게임 개발 튜토리얼 2 (0) | 2010.07.02 |
[MammothHunting] - Cocos2D를 사용한 아이폰 게임 개발 튜토리얼 1 (0) | 2010.07.02 |