cocos2d-iphone之魔塔20层第一部分续

这个魔塔游戏之前使用cocos2d-iphone 1.0做的,有些用cocos2d-iphone 2.0做

的同学就晕了这第一部分的为啥跟我的不一样呢,今天呢我就说一下如何用2.0

做这个游戏,只有第一部分的不一样,后面的部分不变。

其实,这里同样是先把HelloWorldLayer删除掉然后添加Scenemanager和

Menu两个文件,Menu部分代码不变。

Scenemanager.h代码:

#import<GameKit/GameKit.h>

#import"cocos2d.h"

@interface Scenemanager :CCLayer <GKAchievementViewControllerDelegate,GKLeaderboardViewControllerDelegate>

{

}

+(CCScene *) goMenu;

+(CCScene*) goPlay;

@end


Scenemanager.m代码:

#import "Scenemanager.h"
#import "AppDelegate.h"
#import "Menu.h"

#pragma mark - HelloWorldLayer

@implementation Scenemanager
+(CCScene *) goMenu
{
	CCScene *scene = [CCScene node];
	Menu *layer = [Menu node];
	[scene addChild: layer];
	return scene;
}
+(CCScene*)goPlay
{
}
- (void) dealloc
{
	[super dealloc];
}

#pragma mark GameKit delegate

-(void) achievementViewControllerDidFinish:(GKAchievementViewController *)viewController
{
	AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
	[[app navController] dismissModalViewControllerAnimated:YES];
}

-(void) leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController
{
	AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
	[[app navController] dismissModalViewControllerAnimated:YES];
}
@end

接下来把IntroLayer中的“HelloWorldLayer”换成"Scenemanager",然后在把


改成

就好了,之后按照教程写就好了



你可能感兴趣的:(cocos2d)