// 加载每个关卡钟表走动的时间~
-(void) loadLevelDurationTime {
_levelDurationTimeData = [[NSMutableArray
alloc]
init];
int levelTotalCount = [_gCfg
ifk:@"levelTotalCount"];
for(int i =
0; i < levelTotalCount; i ++) {
[_levelDurationTimeData
addObject:@"10"];
// 每关默认10秒钟,如果配置文件中有做配置,则将默认覆盖掉~
}
NSString *absPath = [[NSBundle
mainBundle] pathForResource:@"levelDuration"
ofType:@"txt"];
NSFileManager *fm = [NSFileManager
defaultManager];
if([fm
fileExistsAtPath:absPath] ==
NO) {
NSLog(@"File not exists!");
return;
}
NSString *fileContent = [NSString
stringWithContentsOfFile:absPath
encoding:NSUTF8StringEncoding
error:nil];
//
NSLog(@"file contents:\n%@", fileContent);
NSArray *cfgTime = [fileContent
componentsSeparatedByString:@"\n"];
int lessLength =
MIN( [cfgTime count], [_levelDurationTimeData count] );
for(int i =
0; i < lessLength; i ++) {
[_levelDurationTimeData
replaceObjectAtIndex:i withObject:[cfgTime
objectAtIndex:i]];
//
NSLog(@"第%d关的等待时间长度为: %@", i, [_levelDurationTimeData objectAtIndex:i]);
}
}
//
加载sprite动画的顶点信息~
-(void) loadAnimationData {
_animVerticesDic = [[NSMutableDictionary
alloc] initWithCapacity:20];
NSString *absPath = [[NSBundle
mainBundle] pathForResource:@"animVerticesSummary"
ofType:@"txt"];
NSFileManager *fm = [NSFileManager
defaultManager];
if([fm
fileExistsAtPath:absPath] ==
NO) {
NSLog(@"File not exists!");
return;
}
NSString *fileContent = [NSString
stringWithContentsOfFile:absPath encoding:NSUTF8StringEncoding error:nil];
NSArray *verticesSummaryArray = [fileContent
componentsSeparatedByString:@"\n"];
int len = [verticesSummaryArray
count];
for(int i =
0; i < len; i ++) {
NSString *unit = [verticesSummaryArray
objectAtIndex:i];
NSRange range = [unit
rangeOfString:@"="];
//
NSLog(@"range.location=%d, range.length=%d", range.location, range.length);
NSString *keyStr = [unit
substringToIndex:range.location];
//
NSLog(@"keyString: %@", keyStr);
NSString *valueStr = [unit
substringFromIndex:range.location+1];
//
NSLog(@"valueString: %@", valueStr);
[_animVerticesDic
setObject:valueStr
forKey:keyStr];
}
}