cocos2d scene as a bundle
Hi开发者_Go百科 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.
精彩评论