Scene、Layer基本文件、代码结构in Cocos2d

Scene、Layer基本文件结构

4 Files

1.SomeScene.h
2.SomeScene.m
3.SomeLayer.h
4.SomeLayer.m

SomeScene.h

import <Foundation/Foundation.h>
#import "cocos2d.h"
@interface SomeScene : CCScene {
}
@end

SomeScene.m

#import "SomeScene.h"
#import "SomeLayer.h"
@implementation SomeScene
-(id)init {
    self = [super init];
    if (self != nil) {
        SomeLayer *myLayer = [SomeLayer node];
        [self addChild:myLayer];
    }
    return self;
}
@end

SomeLayer.h

#import <Foundation/Foundation.h>
#import "cocos2d.h"
@interface SomeLayer : CCLayer {
}
@end

SomeLayer.m

#import "SomeLayer.h"
@implementation SomeLayer
-(id)init {
    self = [super init];
    if (self != nil) {
        // add what you want here
    }
    return self;
}
@end

posted on 2013-01-08 12:38  紫澜  阅读(381)  评论(0编辑  收藏  举报