简体   繁体   中英

cocos2d scene as a bundle

Hi is it possible to pack a cocos2d scene in a Bundle (NSBundle) and load it externally (by http for example) ?

Or using any other framework ?

Basically i want to dynamic code load a cocos2d scene in runtime

Regards, Arsénio Costa

One way is you can implement your scene to be as general and configurable as possible and put all the configurations into config files (usually a Property List file). How exactly to do that depends on the type of games you are making, which you didn't specify in your question, but in general your code might look like this:

@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;
}

...

Or, you can try using this cool tool that allows you to visually design your scenes and save them as files to be loaded dynamically in your games: CocosBuilder .

CocosBuilder

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM