2011-08-02 41 views
0

嗨有可能打包一个cocos2d场景在一个Bundle(NSBundle)并加载它外部(例如http)?cocos2d场景作为一个包

还是使用任何其他框架?

基本上我想代码动态负载运行时的cocos2d场景

问候, 阿塞尼奥哥斯达黎加

回答

0

一种方法是你可以实现你的场景是作为一般配置为可能,把所有的配置进入配置文件(通常是一个属性列表文件)。究竟是如何做到这一点取决于游戏中,你正在,你没有在你的问题中指定的类型,但一般你的代码可能是这样的:

@implementation LevelScene 

-(id) initWithConfigFile:(NSString *)configFile { 
    self = [self init]; 
    if (self) { 
     NSDictionary *config = [NSDictionary dictionaryWithContentsOfFile:configFile]; 

     // do further initialization based on values in config 

    } 
    return self; 
} 

... 

或者,你可以尝试使用这个凉爽工具,可以让你在视觉上设计你的场景并将它们保存为动态加载到游戏中的文件:CocosBuilder

CocosBuilder