WEB开发网
开发学院手机开发iPhone 开发 iPhone 开发基础教程 阅读

iPhone 开发基础教程

 2010-08-23 05:15:00 来源:WEB开发网   
核心提示://修改 GameScene.m使其看起来如下:#import “GameScene.h”#import “MenuScene.h”@implementation GameScene- (id) init {self = [super init];if (self != nil) {Sprite * bg = [Spr

//修改 GameScene.m使其看起来如下:

#import “GameScene.h”

#import “MenuScene.h”@implementation GameScene

- (id) init {

self = [super init];

if (self != nil) {

Sprite * bg = [Sprite spriteWithFile:@"game.png"];

[bg setPosition:cpv(240, 160)];

[self add:bg z:0];

[self add:[GameLayer node] z:1];

}

return self;

}

@end

@implementation GameLayer

- (id) init {

self = [super init];

if (self != nil) {

isTouchEnabled = YES;

}

return self;

}

- (BOOL)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

MenuScene * ms = [MenuScene node];

[[Director sharedDirector] replaceScene:ms];

return kEventHandled;

}

@end

//最后,我们要回去MenuLayer类中更新startGame方法,修改如下:

-(void)startGame: (id)sender {

GameScene * gs = [GameScene node];

[[Director sharedDirector] replaceScene:gs];

}

大胆的创建这个项目,沉浸在成功的喜悦几秒钟吧.Cocos2d iPhone最好的地方就是从这里开始一切都变得简单了,困难的地方已经结束了. via:http://www.cnblogs.com/lm3515/archive/2010/08/23/1806191.html

上一页  1 2 3 4 5 6 

Tags:iPhone 开发 基础

编辑录入:coldstar [复制链接] [打 印]
赞助商链接